26 #include <Classes.hpp>
27 #include <Controls.hpp>
28 #include <StdCtrls.hpp>
30 #include <Buttons.hpp>
31 #include <ExtCtrls.hpp>
33 #include <Dialogs.hpp>
34 #include <Graphics.hpp>
35 #include <ComCtrls.hpp>
51 #pragma package(smart_init)
64 Graphics::TBitmap* SmallGraphicPtrVal) : SpeedTag(SpeedTagVal), TrackType(TrackTypeVal), GraphicPtr(GraphicPtrVal), SmallGraphicPtr(SmallGraphicPtrVal)
66 for(
int x = 0; x < 4; x++)
77 else if(SpeedTagVal == 77)
81 else if(SpeedTagVal == 78)
85 else if(SpeedTagVal == 79)
89 else if(SpeedTagVal == 96)
93 else if(SpeedTagVal == 129)
97 else if(SpeedTagVal == 130)
101 else if(SpeedTagVal == 131)
105 else if(SpeedTagVal == 145)
109 else if(SpeedTagVal == 146)
118 FixedNamedLocationElement(false)
120 for(
int x = 0; x < 4; x++)
131 AnsiString(VLocInput));
144 if((this->
HLoc == RHElement.
HLoc) && (this->VLoc == RHElement.
VLoc) && (this->SpeedTag == RHElement.
SpeedTag))
158 if((this->
HLoc != RHElement.
HLoc) || (this->VLoc != RHElement.
VLoc) || (this->SpeedTag != RHElement.
SpeedTag))
174 Graphics::TBitmap *GraphicOutput = GraphicPtr;
176 if(LocationName ==
"")
221 GraphicOutput = GraphicPtr;
225 Disp->PlotOutput(34, HLoc * 16, VLoc * 16, GraphicOutput);
227 if((TrackType ==
Simple) && Failed)
239 AnsiString LogString =
"TrkEl:-," + AnsiString(ElementID) +
"," + LocationName +
"," + AnsiString(TrainIDOnElement) +
"," +
240 AnsiString(TrainIDOnBridgeOrFailedPointOrigSpeedLimit01) +
"," + AnsiString(TrainIDOnBridgeOrFailedPointOrigSpeedLimit23) +
",EndTrkEl,";
249 Attribute(0), CallingOnSet(false), Length01(
Utilities->DefaultTrackLength), Length23(-1), SpeedLimit01(
Utilities->DefaultTrackSpeedLimit), SpeedLimit23(-1),
250 TrainIDOnElement(-1), TrainIDOnBridgeOrFailedPointOrigSpeedLimit01(-1), TrainIDOnBridgeOrFailedPointOrigSpeedLimit23(-1), StationEntryStopLinkPos1(-1), StationEntryStopLinkPos2(-1),
251 SigAspect(FourAspect)
254 for(
int x = 0; x < 4; x++)
270 if(lower.second < higher.second)
274 else if(lower.second > higher.second)
278 else if(lower.second == higher.second)
280 if(lower.first < higher.first)
293 :
TTrackElement(ElementIn), ELink(ELinkIn), ELinkPos(ELinkPosIn), XLink(XLinkIn), XLinkPos(XLinkPosIn), TrackVectorPosition(TrackVectorPositionIn),
294 CheckCount(9), IsARoute(false), AutoSignals(false), PrefDirRoute(false)
298 throw Exception(
"EXNumber failure in TPrefDirElement constructor");
309 AnsiString LogString =
"PthEl:-," + AnsiString(
ELink) +
"," + AnsiString(
ELinkPos) +
"," + AnsiString(
XLink) +
"," + AnsiString(
XLinkPos) +
"," +
337 {2, 4}, {6, 2}, {8, 6}, {4, 8},
338 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
348 else if(
Link[2] == -1)
361 else if(
Link[2] == -1)
370 for(
int x = 0; x < 16; x++)
372 if(((Entry == EXArray[x][0]) && (Exit == EXArray[x][1])) || ((Entry == EXArray[x][1]) && (Exit == EXArray[x][0])))
548 throw Exception(
"Error in EntryExitNumber 4");
643 throw Exception(
"Error in EntryExitNumber 5");
737 throw Exception(
"Error in EntryExitNumber 6");
824 throw Exception(
"Error in EntryExitNumber 10");
913 throw Exception(
"Error in EntryExitNumber 11");
1009 throw Exception(
"Error in EntryExitNumber 7");
1040 throw Exception(
"Error in EntryExitNumber 8");
1051 if((ELink > 0) && (ELink < 10) && (ELink != 5))
1053 if(!AutoSigsFlag && !PrefDirRoute)
1057 else if(!AutoSigsFlag && PrefDirRoute)
1068 throw Exception(
"Error in EntryExitNumber 9");
1165 AnsiString NL =
'\n';
1167 RouteFailMessage =
"Unable to set a route:" + NL + NL +
"it may be unreachable, perhaps because of failed points; " + NL + NL +
1168 "reachable but with too many different directions leading away from the start point - set some points on the route required; " + NL + NL +
1169 "blocked by a train, another route or a changing level crossing; " + NL + NL +
1170 "or invalid - possibly due to a preferred direction mismatch, or a missed signal in a blue route or green route restricted to consecutive signals.";
1177 int InternalLinkCheckArray[9][2] =
1178 {{1, 9}, {4, 6}, {7, 3}, {2, 8}, {0, 0}, {8, 2}, {3, 7}, {6, 4}, {9, 1}};
1183 for(
int x = 0; x < 9; x++)
1185 for(
int y = 0; y < 2; y++)
1192 TopPlatAllowed << 1 << 9 << 10 << 30 << 31 << 60 << 61 << 68 << 69 << 77 << 125 << 126 << 129 << 145;
1194 BotPlatAllowed << 1 << 7 << 8 << 28 << 29 << 60 << 61 << 68 << 69 << 76 << 125 << 126 << 129 << 145;
1195 LeftPlatAllowed << 2 << 12 << 14 << 33 << 35 << 62 << 63 << 70 << 71 << 79 << 127 << 128 << 130 << 146;
1196 RightPlatAllowed << 2 << 11 << 13 << 32 << 34 << 62 << 63 << 70 << 71 << 78 << 127 << 128 << 130 << 146;
1197 NameAllowed << 1 << 2 << 3 << 4 << 5 << 6 << 20 << 21 << 22 << 23 << 24 << 25 << 26 << 27
1198 << 60 << 61 << 62 << 63 << 68 << 69 << 70 << 71 << 80 << 81 << 82 << 83 << 125 << 126 << 127 << 128;
1204 int HVArray[10][2] =
1205 {{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};
1207 for(
int x = 0; x < 10; x++)
1209 for(
int y = 0; y < 2; y++)
1218 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1221 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1222 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1224 {68, 2,
RailGraphics->
bm68dblyellow}, {69, 2,
RailGraphics->
bm69dblyellow}, {70, 2,
RailGraphics->
bm70dblyellow}, {71, 2,
RailGraphics->
bm71dblyellow},
1225 {72, 2,
RailGraphics->
bm72dblyellow}, {73, 2,
RailGraphics->
bm73dblyellow}, {74, 2,
RailGraphics->
bm74dblyellow}, {75, 2,
RailGraphics->
bm75dblyellow},
1227 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1228 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1231 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1234 for(
int x = 0; x < 40; x++)
1240 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1243 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1244 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1246 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1247 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1249 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1250 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1253 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1256 for(
int x = 0; x < 40; x++)
1262 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1265 {68, 1,
RailGraphics->
bm68green}, {69, 1,
RailGraphics->
bm69green}, {70, 1,
RailGraphics->
bm70green}, {71, 1,
RailGraphics->
bm71green},
1266 {72, 1,
RailGraphics->
bm72green}, {73, 1,
RailGraphics->
bm73green}, {74, 1,
RailGraphics->
bm74green}, {75, 1,
RailGraphics->
bm75green},
1268 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1269 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1271 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1272 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1275 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1278 for(
int x = 0; x < 40; x++)
1304 for(
int x = 0; x < 40; x++)
1310 {{68, 0,
RailGraphics->
FSig68}, {69, 0,
RailGraphics->
FSig69}, {70, 0,
RailGraphics->
FSig70}, {71, 0,
RailGraphics->
FSig71}, {72, 0,
RailGraphics->
FSig72},
1313 for(
int x = 0; x < 8; x++)
1319 {{68, 0,
RailGraphics->
FGSig68}, {69, 0,
RailGraphics->
FGSig69}, {70, 0,
RailGraphics->
FGSig70}, {71, 0,
RailGraphics->
FGSig71}, {72, 0,
RailGraphics->
FGSig72},
1322 for(
int x = 0; x < 8; x++)
1349 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1350 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1351 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {0, 0, 77}, {-1, 0, 78},
1352 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1353 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, -1, 129},
1354 {0, 0, 129}, {0, -1, 145},
1357 for(
int x = 0; x < 25; x++)
1359 for(
int y = 0; y < 3; y++)
1367 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1368 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {0, 0, 76}, {-1, 0, 77},
1369 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1370 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1371 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1372 {0, 0, 129}, {0, 1, 145},
1375 for(
int x = 0; x < 25; x++)
1377 for(
int y = 0; y < 3; y++)
1385 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1386 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1387 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1388 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1389 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 0, 79}, {-1, 0, 130},
1390 {0, 0, 130}, {-1, 0, 146},
1393 for(
int x = 0; x < 25; x++)
1395 for(
int y = 0; y < 3; y++)
1403 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1404 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1405 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1406 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {0, 0, 78}, {-1, 0, 79},
1407 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {1, 0, 130},
1408 {0, 0, 130}, {1, 0, 146},
1411 for(
int x = 0; x < 25; x++)
1413 for(
int y = 0; y < 3; y++)
1421 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1422 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1423 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1424 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1425 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1426 {0, -1, 129}, {1, 0, 130},
1427 {-1, 0, 130}, {0, 1, 145},
1428 {0, -1, 145}, {1, 0, 146},
1431 for(
int x = 0; x < 28; x++)
1433 for(
int y = 0; y < 3; y++)
1451 for(
int x = 0; x < 8; x++)
1453 for(
int y = 0; y < 3; y++)
1471 for(
int x = 0; x < 8; x++)
1473 for(
int y = 0; y < 3; y++)
1491 for(
int x = 0; x < 8; x++)
1493 for(
int y = 0; y < 3; y++)
1511 for(
int x = 0; x < 8; x++)
1513 for(
int y = 0; y < 3; y++)
1521 {1, 0, 131}, {0, -1, 131}, {0, 1, 131}};
1523 for(
int x = 0; x < 4; x++)
1525 for(
int y = 0; y < 3; y++)
1533 0, 1, 2, 5, 6, 3, 4, 9, 10, 7, 8, 13, 14, 11, 12, 15, 16, 17, 19, 18, 22, 23, 20, 21, 26, 27, 24, 25, 30, 31, 28, 29, 34, 35, 32, 33, 38, 39, 36, 37, 42,
1534 43, 40, 41, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 60, 61, 63, 62, 66, 67, 64, 65, 68, 69, 71, 70, 74, 75, 72, 73, 77, 76, 78,
1535 79, 80, 81, 83, 82, 86, 87, 84, 85, 88, 89, 91, 90, 94, 95, 92, 93, 96, 99, 100, 97, 98, 103, 104, 101, 102, 106, 105, 109, 110, 107, 108, 113, 114,
1536 111, 112, 117, 118, 115, 116, 119, 120, 121, 123, 122, 124, 125, 126, 128, 127, 129, 130, 131, 134, 133, 132, 135, 139, 138, 137, 136, 143, 142, 141,
1542 0, 1, 2, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15, 16, 17, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41,
1543 40, 43, 42, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 62, 63, 65, 64, 67, 66, 69, 68, 70, 71, 73, 72, 75, 74, 76, 77, 79,
1544 78, 81, 80, 82, 83, 85, 84, 87, 86, 89, 88, 90, 91, 93, 92, 95, 94, 96, 98, 97, 100, 99, 102, 101, 104, 103, 106, 105, 108, 107, 110, 109, 112, 111,
1545 114, 113, 116, 115, 118, 117, 119, 120, 124, 122, 123, 121, 126, 125, 127, 128, 129, 130, 131, 132, 135, 134, 133, 137, 136, 139, 138, 142, 143, 140,
1551 0, 2, 1, 4, 6, 3, 5, 14, 12, 13, 11, 7, 9, 8, 10, 15, 16, 17, 19, 18, 25, 27, 24, 26, 21, 23, 20, 22, 35, 33, 34, 32, 28, 30, 29, 31, 41, 43, 40, 42, 37,
1552 39, 36, 38, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 63, 62, 60, 61, 65, 67, 64, 66, 71, 70, 68, 69, 73, 75, 72, 74, 79, 78, 76,
1553 77, 83, 82, 80, 81, 85, 87, 84, 86, 91, 90, 88, 89, 93, 95, 92, 94, 96, 102, 104, 101, 103, 98, 100, 97, 99, 106, 105, 108, 110, 107, 109, 116, 118,
1554 115, 117, 112, 114, 111, 113, 120, 119, 122, 124, 121, 123, 127, 128, 126, 125, 130, 129, 131, 133, 134, 135, 132, 137, 138, 139, 136, 143, 142, 140,
1560 0, 2, 1, 5, 3, 6, 4, 11, 13, 12, 14, 10, 8, 9, 7, 15, 16, 17, 19, 18, 26, 24, 27, 25, 22, 20, 23, 21, 32, 34, 33, 35, 31, 29, 30, 28, 42, 40, 43, 41, 38,
1561 36, 39, 37, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 62, 63, 61, 60, 66, 64, 67, 65, 70, 71, 69, 68, 74, 72, 75, 73, 78, 79, 77,
1562 76, 82, 83, 81, 80, 86, 84, 87, 85, 90, 91, 89, 88, 94, 92, 95, 93, 96, 103, 101, 104, 102, 99, 97, 100, 98, 106, 105, 109, 107, 110, 108, 117, 115,
1563 118, 116, 113, 111, 114, 112, 120, 119, 123, 121, 124, 122, 128, 127, 125, 126, 130, 129, 131, 135, 132, 133, 134, 139, 136, 137, 138, 142, 143, 141,
1585 delete UGMIt->second;
1661 Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
1662 Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
1664 Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
1671 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1672 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1685 {4, 6, -1, -1}, {2, 8, -1, -1}, {6, 8, -1, -1}, {4, 8, -1, -1}, {2, 6, -1, -1}, {2, 4, -1, -1},
1686 {4, 6, 4, 2}, {6, 4, 6, 2}, {4, 6, 4, 8}, {6, 4, 6, 8}, {8, 2, 8, 4}, {8, 2, 8, 6}, {2, 8, 2, 4}, {2, 8, 2, 6},
1688 {4, 6, 2, 8}, {1, 9, 3, 7},
1690 {3, 7, -1, -1}, {1, 9, -1, -1}, {7, 6, -1, -1}, {4, 9, -1, -1}, {1, 6, -1, -1}, {4, 3, -1, -1}, {3, 8, -1, -1}, {1, 8, -1, -1}, {2, 9, -1, -1},
1692 {4, 6, 4, 3}, {6, 4, 6, 1}, {4, 6, 4, 9}, {6, 4, 6, 7}, {8, 2, 8, 1}, {8, 2, 8, 3}, {2, 8, 2, 7}, {2, 8, 2, 9}, {9, 1, 9, 2}, {7, 3, 7, 2}, {3, 7, 3, 8}, {1, 9, 1, 8}, {9, 1, 9, 4}, {7, 3, 7, 6}, {3, 7, 3, 4}, {1, 9, 1, 6},
1695 {1, 9, 2, 8}, {2, 8, 3, 7}, {4, 6, 3, 7}, {1, 9, 4, 6},
1696 {2, 8, 4, 6}, {4, 6, 2, 8}, {3, 7, 1, 9}, {1, 9, 3, 7}, {2, 8, 1, 9}, {2, 8, 3, 7}, {3, 7, 2, 8}, {1, 9, 2, 8}, {4, 6, 3, 7}, {4, 6, 1, 9}, {1, 9, 4, 6}, {3, 7, 4, 6},
1697 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1698 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1},
1699 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1700 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1701 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1703 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1704 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1705 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1706 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1707 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1},
1708 {4, 6, -1, -1}, {2, 8, -1, -1},
1710 {8, 1, 8, 3}, {4, 3, 4, 9}, {2, 9, 2, 7}, {6, 7, 6, 1}, {9, 4, 9, 2}, {7, 2, 7, 6}, {1, 6, 1, 8}, {3, 8, 3, 4},
1712 {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1}, {1, 9, -1, -1},
1714 {4, 6, -1, -1}, {2, 8, -1, -1},
1719 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1720 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1721 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1722 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1725 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1726 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1727 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1729 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1730 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1731 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1733 {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn},
1735 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1736 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1737 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1738 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1739 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1740 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1741 {
Connection,
Signal,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1742 {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1743 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1744 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1745 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1746 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1747 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1749 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1750 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1751 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1752 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1753 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1754 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1755 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1756 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1760 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1761 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1762 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1768 for(
int x = 0; x < 17; x++)
1770 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1772 FixedTrackPiece[17] =
TFixedTrackPiece(17, TrackTypeArray[17], Links[17], Configs[17], 0, 0);
1776 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1782 ExistingGraphicLoaded(false), Width(16), Height(16)
1794 ExistingGraphicLoaded(false), Width(WidthIn), Height(HeightIn)
1832 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalScreenGraphic()");
1836 throw Exception(
"Overlay not 16x16 in TGraphicElement::LoadOriginalScreenGraphic()");
1840 throw Exception(
"Source not set in TGraphicElement::LoadOriginalScreenGraphic()");
1844 throw Exception(
"ExistingGraphicLoaded in TGraphicElement::LoadOriginalScreenGraphic()");
1867 AnsiString(VOffset) +
"," + AnsiString(WidthIn) +
"," + AnsiString(HeightIn));
1870 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalExistingGraphic()");
1874 throw Exception(
"Source not set in TGraphicElement::LoadOriginalExistingGraphic()");
1878 throw Exception(
"ScreenGraphicLoaded in TGraphicElement::LoadOriginalExistingGraphic()");
1912 throw Exception(
"Overlay not loaded in TGraphicElement::PlotOverlay()");
1933 throw Exception(
"Original not loaded in TGraphicElement::PlotOriginal()");
1947 bool TrackPresent =
false;
1961 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1965 TrackPresent =
true;
1970 return(!TrackPresent);
1978 bool TrackPresent =
false;
1987 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1991 TrackPresent =
true;
1997 return(!TrackPresent);
2002 void TTrack::EraseTrackElement(
int Caller,
int HLocInput,
int VLocInput,
int &ErasedTrackVectorPosition,
bool &TrackEraseSuccessfulFlag,
bool InternalChecks)
2005 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2006 TrackEraseSuccessfulFlag =
false;
2011 ErasedTrackVectorPosition = -1;
2012 AnsiString SName =
"", ErrorString;
2014 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
2020 TrackMapKeyPair.first = HLocInput;
2021 TrackMapKeyPair.second = VLocInput;
2022 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
2033 if(ErrorString !=
"")
2035 throw Exception(ErrorString +
" for EraseTrackElement 1");
2059 ErasedTrackVectorPosition = VecPos;
2060 TrackEraseSuccessfulFlag =
true;
2066 unsigned int VecPos;
2067 InactiveTrackMapKeyPair.first = HLocInput;
2068 InactiveTrackMapKeyPair.second = VLocInput;
2073 VecPos = InactiveTrack2MultiMapIterator->second;
2078 if(ErrorString !=
"")
2080 throw Exception(ErrorString +
" for EraseTrackElement 2A");
2090 TrackEraseSuccessfulFlag =
true;
2111 VecPos = InactiveTrack2MultiMapIterator->second;
2116 if(ErrorString !=
"")
2118 throw Exception(ErrorString +
" for EraseTrackElement 2B");
2142 if(TrackEraseSuccessfulFlag)
2164 AnsiString(HLocInput) +
"," + AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2165 bool PlatAllowedFlag =
false;
2167 TrackLinkingRequiredFlag =
false;
2179 LocationNameEntry.first =
"";
2187 TempTrackElement.
HLoc = HLocInput;
2188 TempTrackElement.
VLoc = VLocInput;
2214 else if(Aspect == 1)
2218 else if(Aspect == 2)
2222 else if(Aspect == 3)
2231 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2234 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2236 if(InactiveFoundFlag)
2240 NonStationOrLevelCrossingPresent =
true;
2244 NonStationOrLevelCrossingPresent =
true;
2248 PlatformPresent =
true;
2259 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2267 PlatAllowedFlag =
true;
2271 PlatAllowedFlag =
true;
2275 PlatAllowedFlag =
true;
2279 PlatAllowedFlag =
true;
2283 TrackLinkingRequiredFlag =
true;
2311 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1048, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2312 (!FoundFlag && !InactiveFoundFlag))
2315 TrackLinkingRequiredFlag =
true;
2347 TrackLinkingRequiredFlag =
true;
2359 else if(FoundFlag || InactiveFoundFlag)
2378 bool BothPointFillets =
true;
2393 TrackLinkingRequiredFlag =
true;
2407 bool InternalChecks)
2411 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2412 bool PlatAllowedFlag =
false;
2414 TrackLinkingRequiredFlag =
false;
2417 LocationNameEntry.first =
"";
2423 TempTrackElement.
HLoc = HLocInput;
2424 TempTrackElement.
VLoc = VLocInput;
2425 for(
int x = 0; x < 4; x++)
2431 TempTrackElement.
Conn[x] = -1;
2435 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2446 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2448 if(InactiveFoundFlag)
2452 NonStationOrLevelCrossingPresent =
true;
2456 NonStationOrLevelCrossingPresent =
true;
2460 PlatformPresent =
true;
2471 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2479 PlatAllowedFlag =
true;
2483 PlatAllowedFlag =
true;
2487 PlatAllowedFlag =
true;
2491 PlatAllowedFlag =
true;
2495 TrackLinkingRequiredFlag =
true;
2526 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1055, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2527 (!FoundFlag && !InactiveFoundFlag))
2530 TrackLinkingRequiredFlag =
true;
2565 TrackLinkingRequiredFlag =
true;
2577 else if(FoundFlag || InactiveFoundFlag)
2596 bool BothPointFillets =
true;
2611 TrackLinkingRequiredFlag =
true;
2641 ShowMessage(
"Gaps must be set before track can be validated");
2651 throw Exception(
"Error, gaps unset when TryToConnectTrack called");
2662 if(!
LinkTrack(1, LocError, HLoc, VLoc,
false))
2679 ShowMessage(
"Error in RepositionAndMapTrack during TryToConnectTrack. Railway file is corrupt, further use may cause a system crash");
2686 if(!
LinkTrack(2, LocError, HLoc, VLoc,
true))
2710 std::pair<AnsiString, char>TempMapPair;
2718 TempMapPair.second =
'x';
2728 AnsiString Name =
"";
2729 typedef std::list<AnsiString> TNoPlatsList;
2730 TNoPlatsList::iterator NPLIt;
2731 TNoPlatsList NoPlatsList;
2732 typedef std::list<AnsiString> TLocNameList;
2733 TLocNameList LocNameList;
2738 LocNameList.push_back(LNMMIt->first);
2741 LocNameList.unique();
2742 for(TLocNameList::iterator LNLIt = LocNameList.begin(); LNLIt != LocNameList.end(); LNLIt++)
2746 if(MMRange.first == MMRange.second)
2752 if((LNMMIt->second) < 0)
2766 TempIt = MMRange.second;
2767 if(LNMMIt == --TempIt)
2769 NoPlatsList.push_back(Name);
2773 if(!NoPlatsList.empty())
2775 AnsiString NoPlatsAnsiList =
"";
2776 for(NPLIt = NoPlatsList.begin(); NPLIt != NoPlatsList.end(); NPLIt++)
2778 NoPlatsAnsiList += *NPLIt +
'\n';
2782 if(NoPlatsList.size() > 1)
2784 ShowMessage(
"Please note: the following locations have no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2788 ShowMessage(
"Please note: the following location has no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2803 int NewHLoc, NewVLoc;
2804 bool ConnectionFoundFlag, LinkFoundFlag;
2806 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2808 for(
unsigned int y = 0; y < 4; y++)
2826 ConnectionFoundFlag =
false;
2827 for(
unsigned int z = 0; z <
TrackVector.size(); z++)
2833 ConnectionFoundFlag =
true;
2835 LinkFoundFlag =
false;
2836 for(
unsigned int a = 0; a < 4; a++)
2840 LinkFoundFlag =
true;
2856 if(!ConnectionFoundFlag)
2931 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2948 bool UnsetGaps =
false;
2955 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2959 for(
unsigned int y = 0; y < 4; y++)
2971 for(
unsigned int y = 0; y < 4; y++)
2981 for(
unsigned int y = 1; y < 4; y++)
2990 for(
unsigned int y = 0; y < 4; y++)
3003 for(
unsigned int y = 0; y < 4; y++)
3031 int NumberOfActiveElements = 0;
3033 GraphicsFollow =
false;
3037 if(MarkerString[MarkerString.Length()] ==
'1')
3039 GraphicsFollow =
true;
3041 for(
int x = 0; x < NumberOfActiveElements; x++)
3047 TrackElement.
HLoc = TempInt;
3049 TrackElement.
VLoc = TempInt;
3055 TrackElement.
Conn[0] = TempInt;
3079 if((TempInt != -1) && (TempInt < 10))
3089 if((TempInt != -1) && (TempInt < 10))
3106 if(Marker[1] ==
'3')
3110 else if(Marker[1] ==
'2')
3114 else if(Marker[1] ==
'G')
3128 int NumberOfInactiveElements = 0;
3132 for(
int x = 0; x < NumberOfInactiveElements; x++)
3138 TrackElement.
HLoc = TempInt;
3140 TrackElement.
VLoc = TempInt;
3146 bool LocError =
false;
3175 for(
int x = 0; x < NumberOfGraphics; x++)
3186 bool FileError =
false;
3188 for(
int x = 0; x < NumberOfGraphics; x++)
3201 UGME.second =
new TPicture;
3202 UGME.second->LoadFromFile(
UGME.first);
3205 throw Exception(
"Map Insertion Error 2 - UserGraphicMap insertion failure for " + UGI.
FileName);
3212 catch(
const EInvalidGraphic &e)
3221 delete UGMIt->second;
3226 catch(
const Exception &e)
3235 delete UGMIt->second;
3243 bool FoundInMap =
false;
3262 UGME.second =
new TPicture;
3263 UGME.second->LoadFromFile(
UGME.first);
3266 throw Exception(
"Map Insertion Error 3 - UserGraphicMap insertion failure for " + UGI.
FileName);
3273 catch(
const EInvalidGraphic &e)
3282 delete UGMIt->second;
3287 catch(
const Exception &e)
3296 delete UGMIt->second;
3321 VecFile <<
"**Active elements**1" <<
'\0' <<
'\n';
3325 VecFile <<
"**Active elements**" <<
'\0' <<
'\n';
3327 for(
unsigned int x = 0; x < (
TrackVector.size()); x++)
3330 VecFile << x <<
'\n';
3331 VecFile << TrackElement.
SpeedTag <<
'\n';
3332 VecFile << TrackElement.
HLoc <<
'\n';
3333 VecFile << TrackElement.
VLoc <<
'\n';
3337 VecFile << TrackElement.
Conn[0] <<
'\n';
3341 VecFile << TrackElement.
Attribute <<
'\n';
3347 VecFile << int(1) <<
'\n';
3351 VecFile << int(0) <<
'\n';
3354 VecFile << TrackElement.
Length01 <<
'\n';
3355 VecFile << TrackElement.
Length23 <<
'\n';
3358 VecFile << TrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3365 VecFile <<
"3*****" <<
'\0' <<
'\n';
3369 VecFile <<
"2*****" <<
'\0' <<
'\n';
3373 VecFile <<
"G*****" <<
'\0' <<
'\n';
3377 VecFile <<
"4*****" <<
'\0' <<
'\n';
3382 VecFile <<
"******" <<
'\0' <<
'\n';
3387 VecFile <<
"**Inactive elements**" <<
'\0' <<
'\n';
3391 VecFile << x <<
'\n';
3392 VecFile << InactiveTrackElement.
SpeedTag <<
'\n';
3393 VecFile << InactiveTrackElement.
HLoc <<
'\n';
3394 VecFile << InactiveTrackElement.
VLoc <<
'\n';
3395 VecFile << InactiveTrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3396 VecFile <<
"******" <<
'\0' <<
'\n';
3411 GraphicsFollow =
false;
3413 if((NumberOfActiveElements < 0) || (NumberOfActiveElements > 1000000))
3419 AnsiString MarkerString;
3426 if(MarkerString[MarkerString.Length()] ==
'1')
3428 GraphicsFollow =
true;
3430 for(
int x = 0; x < NumberOfActiveElements; x++)
3438 int SpeedTag = TempInt;
3445 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3451 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3456 if((SpeedTag > 87) && (SpeedTag < 96))
3459 if((TempInt < -1) || (TempInt > 3))
3465 if((TempInt < -1) || (TempInt > 999999))
3471 if(((SpeedTag >= 7) && (SpeedTag <= 14)) || ((SpeedTag >= 28) && (SpeedTag <= 43)) || ((SpeedTag >= 132) && (SpeedTag <= 139)) ||
3472 ((SpeedTag >= 68) && (SpeedTag <= 75)))
3475 if((TempInt < -1) || (TempInt > 5))
3481 if((SpeedTag >= 68) && (SpeedTag <= 75))
3484 if((TempInt != 0) && (TempInt != 1))
3491 if((TempInt < -1) || (TempInt > 999999))
3497 if((TempInt < -1) || (TempInt > 999999))
3503 if((TempInt < -1) || (TempInt > 999999))
3509 if((TempInt < -1) || (TempInt > 999999))
3530 int NumberOfInactiveElements = 0;
3533 if(NumberOfInactiveElements < 0)
3543 for(
int x = 0; x < NumberOfInactiveElements; x++)
3557 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3563 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3590 if((NumberOfGraphics < 0) || (NumberOfGraphics > 100000))
3596 AnsiString FileName =
"", TempStr =
"";
3598 for(
int x = 0; x < NumberOfGraphics; x++)
3600 TPicture *TempPicture =
new TPicture;
3609 TempPicture->LoadFromFile(GraphicsPath +
"\\" + FileName);
3622 catch(
const EInvalidGraphic &e)
3627 for(
int y = x + 1; y < NumberOfGraphics; y++)
3633 ShowMessage(FileName +
3634 " has an incorrect file format, user graphics can't be loaded. Ensure that all user graphic files are valid with extension .bmp, .gif, .jpg, or .png");
3639 catch(
const Exception &e)
3644 for(
int y = x + 1; y < NumberOfGraphics; y++)
3650 ShowMessage(
"Unable to load user graphic files, ensure that " + FileName +
3651 " exists in the 'Graphics' folder and that it is has extension .bmp, .gif, .jpg, or .png.");
3669 for(
int x = 0; x < VecSize; x++)
3692 for(
int x = 0; x < VecSize; x++)
3714 for(
int x = 0; x < VecSize; x++)
3768 for(
int x = 0; x < VecSize; x++)
3826 PlotPoints(5, Next, Disp, BothPointFilletsAndBasicLCs);
3848 if(BothPointFilletsAndBasicLCs)
3923 Bitmap->Canvas->CopyMode = cmSrcCopy;
3925 Graphics::TBitmap *GraphicOutput;
4100 for(
int x = 0; x < 40; x++)
4129 Graphics::TBitmap *GraphicPtr;
4144 Graphics::TBitmap* SignalPlatformGraphic;
4177 if(OldTransparentColour !=
clB5G5R5)
4200 Bitmap->Canvas->CopyMode = cmSrcCopy;
4228 Bitmap->Canvas->CopyMode = cmSrcCopy;
4230 Graphics::TBitmap *GraphicOutput;
4240 if(BaseElement == 1)
4336 for(
int x = 0; x < 40; x++)
4365 Graphics::TBitmap *GraphicPtr;
4380 Graphics::TBitmap* SignalPlatformGraphic;
4443 for(
int x = 0; x < 40; x++)
4451 Graphics::TBitmap* SignalPlatformGraphic;
4492 if(OldTransparentColour !=
clB5G5R5)
4506 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4578 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4592 ShowMessage(
"Error - gap connected to a non-gap. Railway file is corrupt, further use may cause a system crash");
4618 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4643 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4673 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4707 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4744 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4761 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4782 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4814 for(TrackMapPtr =
TrackMap.begin(); TrackMapPtr !=
TrackMap.end(); TrackMapPtr++)
4821 throw Exception(
"Error - Map & Vector different sizes");
4823 unsigned int NonZeroCount = 0;
4825 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4834 throw Exception(
"Error - NewVector & NonZero TrackVector different sizes");
4840 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4844 TrackMapEntry.first = TrackMapKeyPair;
4845 TrackMapEntry.second = x;
4846 if(!(
TrackMap.insert(TrackMapEntry).second))
4848 throw Exception(
"Error - map insertion failure, TrackVector in error");
4852 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4854 for(
unsigned int y = 0; y < 4; y++)
4879 THVPair GapMapKeyPair, GapMapValuePair;
4882 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4888 GapMapEntry.first = GapMapKeyPair;
4891 throw Exception(
"Error - Gap connection == -1 Can't build GapMap");
4895 GapMapEntry.second = GapMapValuePair;
4898 GapMap.insert(GapMapEntry);
4913 bool TrackElementPositionsOK =
true;
4915 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4927 "Footbridge or underpass connection error. Each end must connect to a platform, concourse "
4928 "or other footbridge or underpass, and they can't connect to each other (i.e. a footbridge "
4929 "can't connect to an underpass or vice versa)");
4937 for(
unsigned int y = 0; y < 4; y++)
4955 bool ConnectionFoundFlag;
4959 ShowMessage(
"Can't have a track element adjacent to a continuation exit");
4965 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
4974 if(ConnectionFoundFlag)
4979 bool ExitSignal =
false;
4990 ShowMessage(
"Can't have an exit signal next to a level crossing - it can cause the train to foul the crossing in some circumstances");
4992 TrackElementPositionsOK =
false;
4997 ShowMessage(
"Can't have points, crossover or signal next to buffers - need room for a train without fouling");
4999 TrackElementPositionsOK =
false;
5004 ShowMessage(
"Can't have points, crossover, bridge or signal next to a continuation - it can cause route setting problems");
5008 TrackElementPositionsOK =
false;
5013 ShowMessage(
"Can't have two same-direction signals adjacent to each other as there is no room for a train between them");
5016 TrackElementPositionsOK =
false;
5028 ShowMessage(
"Bridge next to a signal - routes can't be truncated to this or other such signals.\n\nThis restriction can be removed or reinstated by pressing\nCTRL ALT 5. When removed this message will not be shown again.");
5031 TrackElementPositionsOK =
false;
5036 ShowMessage(
"Can't have two level crossings adjacent to each other on the same track");
5037 TrackElementPositionsOK =
false;
5040 if(!TrackElementPositionsOK)
5047 throw Exception(
"Error in track element positions in FinalCall");
5060 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5066 for(
unsigned int y = 0; y < 4; y++)
5088 bool ConnectionFoundFlag;
5089 bool LinkMatchFound =
false;
5092 if(ConnectionFoundFlag)
5094 for(
unsigned int a = 0; a < 4; a++)
5103 LinkMatchFound =
true;
5114 throw Exception(
"Error in final track linkage - - no matching link found");
5127 throw Exception(
"Error in final track linkage - connection not found");
5142 bool ConnErrorFlag =
false;
5144 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5148 ConnErrorFlag =
true;
5152 ConnErrorFlag =
true;
5156 ConnErrorFlag =
true;
5160 ConnErrorFlag =
true;
5168 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5177 throw Exception(
"ConnError in LinkTrack - Final");
5181 throw Exception(
"ConnError in LinkTrack - Precheck");
5184 bool CLkErrorFlag =
false;
5186 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5190 CLkErrorFlag =
true;
5194 CLkErrorFlag =
true;
5198 CLkErrorFlag =
true;
5202 CLkErrorFlag =
true;
5210 throw Exception(
"CLkError in LinkTrack - Final");
5214 throw Exception(
"CLkError in LinkTrack - Precheck");
5219 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5249 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5265 for(
unsigned int y = 0; y < 4; y++)
5284 bool ConnectionFoundFlag;
5290 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
5299 if(ConnectionFoundFlag)
5302 bool LinkFoundFlag =
false;
5359 for(
unsigned int a = 0; a < 4; a++)
5368 LinkFoundFlag =
true;
5376 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - invalid link");
5386 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - connection not found");
5399 bool ConnErrorFlag =
false;
5401 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5405 ConnErrorFlag =
true;
5409 ConnErrorFlag =
true;
5413 ConnErrorFlag =
true;
5417 ConnErrorFlag =
true;
5425 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5434 throw Exception(
"ConnError in LinkTrack - Final");
5438 throw Exception(
"ConnError in LinkTrack - Precheck");
5441 bool CLkErrorFlag =
false;
5443 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5447 CLkErrorFlag =
true;
5451 CLkErrorFlag =
true;
5455 CLkErrorFlag =
true;
5459 CLkErrorFlag =
true;
5467 throw Exception(
"CLkError in LinkTrack - Final");
5471 throw Exception(
"CLkError in LinkTrack - Precheck");
5475 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5504 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5520 for(
unsigned int y = 0; y < 4; y++)
5539 bool ConnectionFoundFlag =
false;
5541 if(ConnectionFoundFlag)
5545 bool LinkFoundFlag =
false;
5565 for(
unsigned int a = 0; a < 4; a++)
5574 LinkFoundFlag =
true;
5594 bool ConnErrorFlag =
false;
5596 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5600 ConnErrorFlag =
true;
5604 ConnErrorFlag =
true;
5608 ConnErrorFlag =
true;
5612 ConnErrorFlag =
true;
5620 bool CLkErrorFlag =
false;
5622 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5626 CLkErrorFlag =
true;
5630 CLkErrorFlag =
true;
5634 CLkErrorFlag =
true;
5638 CLkErrorFlag =
true;
5656 int Position1, Position2;
5662 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
5664 int HLoc1 = GapMapPtr->first.first;
5665 int VLoc1 = GapMapPtr->first.second;
5666 int HLoc2 = GapMapPtr->second.first;
5667 int VLoc2 = GapMapPtr->second.second;
5670 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
5674 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
5678 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
5682 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
5700 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
5701 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
5711 bool FoundFlag =
false;
5723 InactiveTrackMapKeyPair.first = TrackElement.
HLoc;
5724 InactiveTrackMapKeyPair.second = TrackElement.
VLoc;
5725 InactiveTrackMapEntry.first = InactiveTrackMapKeyPair;
5754 bool FoundFlag =
false;
5767 TrackMapKeyPair.first = TrackElement.
HLoc;
5768 TrackMapKeyPair.second = TrackElement.
VLoc;
5769 TrackMapEntry.first = TrackMapKeyPair;
5774 LocationNameEntry.second = -(int)(
TrackVector.size());
5814 TrackMapKeyPair.first = HLoc;
5815 TrackMapKeyPair.second = VLoc;
5816 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5826 return(TrackMapPtr->second);
5839 TrackMapKeyPair.first = HLoc;
5840 TrackMapKeyPair.second = VLoc;
5841 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5844 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5845 throw Exception(Message);
5863 MapKeyPair.first = HLoc;
5864 MapKeyPair.second = VLoc;
5865 MapPtr = Map.find(MapKeyPair);
5866 if(MapPtr == Map.end())
5868 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc) +
" in GetTrackElementFromAnyTrackMap";
5869 throw Exception(Message);
5874 return(Vector.at(MapPtr->second));
5884 THVPair InactiveTrackMapKeyPair;
5887 InactiveTrackMapKeyPair.first = HLoc;
5888 InactiveTrackMapKeyPair.second = VLoc;
5892 AnsiString Message =
"Inactive element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5893 throw Exception(Message);
5907 bool Present =
true;
5911 TrackMapKeyPair.first = HLoc;
5912 TrackMapKeyPair.second = VLoc;
5913 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5928 bool Present =
true;
5929 THVPair InactiveTrackMapKeyPair;
5932 InactiveTrackMapKeyPair.first = HLoc;
5933 InactiveTrackMapKeyPair.second = VLoc;
5951 THVPair InactiveTrackMapKeyPair;
5956 InactiveTrackMapKeyPair.first = HLoc;
5957 InactiveTrackMapKeyPair.second = VLoc;
5966 if(InactiveTrackRange.first == InactiveTrackRange.second)
5975 RetPair.first = InactiveTrackRange.first->second;
5976 RetPair.second = (--InactiveTrackRange.second)->second;
5989 AnsiString(DivergingPosition));
6000 if(((SpeedTag1 == 7) && (SpeedTag2 == 10)) ||
6001 ((SpeedTag1 == 10) && (SpeedTag2 == 7)) || ((SpeedTag1 == 8) && (SpeedTag2 == 9)) || ((SpeedTag1 == 9) && (SpeedTag2 == 8)) ||
6002 ((SpeedTag1 == 11) && (SpeedTag2 == 14)) ||
6003 ((SpeedTag1 == 14) && (SpeedTag2 == 11)) || ((SpeedTag1 == 12) && (SpeedTag2 == 13)) || ((SpeedTag1 == 13) && (SpeedTag2 == 12)) ||
6004 ((SpeedTag1 == 28) && (SpeedTag2 == 31)) ||
6005 ((SpeedTag1 == 31) && (SpeedTag2 == 28)) || ((SpeedTag1 == 29) && (SpeedTag2 == 30)) || ((SpeedTag1 == 30) && (SpeedTag2 == 29)) ||
6006 ((SpeedTag1 == 32) && (SpeedTag2 == 35)) ||
6007 ((SpeedTag1 == 35) && (SpeedTag2 == 32)) || ((SpeedTag1 == 33) && (SpeedTag2 == 34)) || ((SpeedTag1 == 34) && (SpeedTag2 == 33)) ||
6008 ((SpeedTag1 == 36) && (SpeedTag2 == 39)) ||
6009 ((SpeedTag1 == 39) && (SpeedTag2 == 36)) || ((SpeedTag1 == 37) && (SpeedTag2 == 38)) || ((SpeedTag1 == 38) && (SpeedTag2 == 37)) ||
6010 ((SpeedTag1 == 40) && (SpeedTag2 == 43)) ||
6011 ((SpeedTag1 == 43) && (SpeedTag2 == 40)) || ((SpeedTag1 == 41) && (SpeedTag2 == 42)) || ((SpeedTag1 == 42) && (SpeedTag2 == 41)))
6045 throw Exception(
"Error, Wrong track type in PlotGap");
6047 if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] > -1))
6051 else if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] == -1))
6055 if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] > -1))
6059 else if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] == -1))
6063 if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] > -1))
6067 else if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] == -1))
6071 if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] > -1))
6075 else if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] == -1))
6079 if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] > -1))
6083 else if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] == -1))
6087 if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] > -1))
6091 else if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] == -1))
6095 if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] > -1))
6099 else if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] == -1))
6103 if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] > -1))
6107 else if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] == -1))
6123 PosPair.first = TrackElement.
HLoc;
6124 PosPair.second = TrackElement.
VLoc;
6128 Disp->
PlotOutput(283, TrackElement.
HLoc * 16, TrackElement.
VLoc * 16, MOMIt->second);
6141 throw Exception(
"Error, Wrong track type in PlotPoints");
6152 else if(TrackElement.
SpeedTag < 132)
6163 else if(!TrackElement.
Failed)
6170 else if(TrackElement.
SpeedTag < 132)
6188 else if(TrackElement.
SpeedTag < 132)
6222 throw Exception(
"Error, Wrong track type in PlotSignal");
6226 for(
int x = 0; x < 40; x++)
6297 for(
int x = 0; x < 40; x++)
6304 Graphics::TBitmap* SignalPlatformGraphic;
6319 for(
int x = 0; x < 8; x++)
6334 for(
int x = 0; x < 8; x++)
6425 while(
IsLCAtHV(0, HLoc, (VLoc + UpStep)))
6433 while(
IsLCAtHV(1, HLoc, (VLoc + DownStep)))
6441 while(
IsLCAtHV(2, (HLoc + LeftStep), VLoc))
6449 while(
IsLCAtHV(3, (HLoc + RightStep), VLoc))
6465 while(
IsLCAtHV(51, HLoc, (VLoc + UpStep)))
6473 while(
IsLCAtHV(52, HLoc, (VLoc + DownStep)))
6481 while(
IsLCAtHV(53, (HLoc + LeftStep), VLoc))
6489 while(
IsLCAtHV(54, (HLoc + RightStep), VLoc))
6522 while(
IsLCAtHV(55, HLoc, (VLoc + UpStep)))
6534 while(
IsLCAtHV(56, HLoc, (VLoc + DownStep)))
6546 while(
IsLCAtHV(57, (HLoc + LeftStep), VLoc))
6558 while(
IsLCAtHV(58, (HLoc + RightStep), VLoc))
6600 throw Exception(
"Error, Wrong track type in PlotAndLowerLevelCrossingBarriers");
6602 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6604 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndLowerLevelCrossingBarriers");
6607 if(BaseElementSpeedTag == 1)
6611 while(
IsLCAtHV(5, HLoc, (VLoc + UpStep)))
6618 while(
IsLCAtHV(6, HLoc, (VLoc + DownStep)))
6626 Graphics::TBitmap *RouteGraphic;
6628 if(TypeOfRoute == 1)
6632 else if(TypeOfRoute == 0)
6638 RouteGraphic = BaseGraphic;
6645 if(UpStep == DownStep)
6648 Disp->
PlotOutput(133, HLoc * 16, VLoc * 16, RouteGraphic);
6658 else if((DownStep - UpStep) == 1)
6663 Disp->
PlotOutput(136, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6673 Disp->
PlotOutput(139, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6686 Disp->
PlotOutput(196, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6696 Disp->
PlotOutput(199, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6712 Disp->
PlotOutput(142, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6722 Disp->
PlotOutput(145, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6732 else if(DownStep == 0)
6735 Disp->
PlotOutput(202, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6745 Disp->
PlotOutput(205, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6758 Disp->
PlotOutput(208, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6768 Disp->
PlotOutput(211, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6778 for(
int x = (UpStep + 1); x < DownStep; x++)
6783 Disp->
PlotOutput(148, HLoc * 16, (VLoc + x) * 16, RouteGraphic);
6787 Disp->
PlotOutput(213, HLoc * 16, (VLoc + x) * 16, BaseGraphic);
6808 while(
IsLCAtHV(7, (HLoc + LStep), VLoc))
6815 while(
IsLCAtHV(8, (HLoc + RStep), VLoc))
6821 Graphics::TBitmap *RouteGraphic;
6823 if(TypeOfRoute == 1)
6827 else if(TypeOfRoute == 0)
6833 RouteGraphic = BaseGraphic;
6842 Disp->
PlotOutput(151, HLoc * 16, VLoc * 16, RouteGraphic);
6852 else if((RStep - LStep) == 1)
6857 Disp->
PlotOutput(154, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6867 Disp->
PlotOutput(157, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6880 Disp->
PlotOutput(215, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6890 Disp->
PlotOutput(218, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6906 Disp->
PlotOutput(160, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6916 Disp->
PlotOutput(163, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6929 Disp->
PlotOutput(221, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6939 Disp->
PlotOutput(224, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6952 Disp->
PlotOutput(227, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6962 Disp->
PlotOutput(230, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6972 for(
int x = (LStep + 1); x < RStep; x++)
6977 Disp->
PlotOutput(166, (HLoc + x) * 16, VLoc * 16, RouteGraphic);
6981 Disp->
PlotOutput(232, (HLoc + x) * 16, VLoc * 16, BaseGraphic);
7005 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7008 throw Exception(
"Error, Wrong track type in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
7010 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7012 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
7015 if(BaseElementSpeedTag == 1)
7019 while(
IsLCAtHV(30, HLoc, (VLoc + UpStep)))
7026 while(
IsLCAtHV(31, HLoc, (VLoc + DownStep)))
7032 if(UpStep == DownStep)
7043 else if((DownStep - UpStep) == 1)
7062 for(
int x = (UpStep + 1); x < DownStep; x++)
7071 for(
int x = (UpStep + 1); x < DownStep; x++)
7078 for(
int x = UpStep; x <= DownStep; x++)
7091 while(
IsLCAtHV(32, (HLoc + LStep), VLoc))
7098 while(
IsLCAtHV(33, (HLoc + RStep), VLoc))
7115 else if((RStep - LStep) == 1)
7134 for(
int x = (LStep + 1); x < RStep; x++)
7143 for(
int x = (LStep + 1); x < RStep; x++)
7150 for(
int x = LStep; x <= RStep; x++)
7169 throw Exception(
"Error, Wrong track type in PlotAndRaiseLevelCrossingBarriers");
7171 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7173 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndRaiseLevelCrossingBarriers");
7176 if(BaseElementSpeedTag == 1)
7180 while(
IsLCAtHV(10, HLoc, (VLoc + UpStep)))
7187 while(
IsLCAtHV(11, HLoc, (VLoc + DownStep)))
7193 for(
int x = UpStep; x < (DownStep + 1); x++)
7208 while(
IsLCAtHV(12, (HLoc + LStep), VLoc))
7215 while(
IsLCAtHV(13, (HLoc + RStep), VLoc))
7221 for(
int x = LStep; x < (RStep + 1); x++)
7240 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7243 throw Exception(
"Error, Wrong track type in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
7245 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7247 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
7252 if(BaseElementSpeedTag == 1)
7256 while(
IsLCAtHV(35, HLoc, (VLoc + UpStep)))
7263 while(
IsLCAtHV(36, HLoc, (VLoc + DownStep)))
7269 for(
int x = UpStep; x <= DownStep; x++)
7283 while(
IsLCAtHV(37, (HLoc + LStep), VLoc))
7290 while(
IsLCAtHV(38, (HLoc + RStep), VLoc))
7296 for(
int x = LStep; x <= RStep; x++)
7312 Graphics::TBitmap *RouteGraphic;
7315 if(BaseElementSpeedTag == 1)
7317 if(TypeOfRoute == 1)
7321 else if(TypeOfRoute == 0)
7327 RouteGraphic = BaseGraphic;
7331 RouteGraphic = BaseGraphic;
7337 if(TypeOfRoute == 1)
7341 else if(TypeOfRoute == 0)
7347 RouteGraphic = BaseGraphic;
7351 RouteGraphic = BaseGraphic;
7356 while(
IsLCAtHV(14, HLoc, (VLoc + UpStep)))
7361 Disp->
PlotOutput(175, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
7365 Disp->
PlotOutput(234, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
7372 while(
IsLCAtHV(15, HLoc, (VLoc + DownStep)))
7375 Disp->
PlotOutput(177, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
7380 while(
IsLCAtHV(16, (HLoc + LeftStep), VLoc))
7385 Disp->
PlotOutput(235, (HLoc + LeftStep) * 16, VLoc * 16, RouteGraphic);
7389 Disp->
PlotOutput(236, (HLoc + LeftStep) * 16, VLoc * 16, BaseGraphic);
7396 while(
IsLCAtHV(17, (HLoc + RightStep), VLoc))
7399 Disp->
PlotOutput(238, (HLoc + RightStep) * 16, VLoc * 16, BaseGraphic);
7524 throw Exception(
"Element not found in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7528 throw Exception(
"Element not a level crossing in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7559 "," + AnsiString(VLoc));
7563 int DummyRouteNumber;
7565 TrainPresent =
false;
7569 while(
IsLCAtHV(25, HLoc, (VLoc + UpStep)))
7571 TrackMapKeyPair.first = HLoc;
7572 TrackMapKeyPair.second = VLoc + UpStep;
7573 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7582 TrainPresent =
true;
7596 while(
IsLCAtHV(26, HLoc, (VLoc + DownStep)))
7598 TrackMapKeyPair.first = HLoc;
7599 TrackMapKeyPair.second = VLoc + DownStep;
7600 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7609 TrainPresent =
true;
7623 while(
IsLCAtHV(27, (HLoc + LeftStep), VLoc))
7625 TrackMapKeyPair.first = HLoc + LeftStep;
7626 TrackMapKeyPair.second = VLoc;
7627 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7636 TrainPresent =
true;
7650 while(
IsLCAtHV(28, (HLoc + RightStep), VLoc))
7652 TrackMapKeyPair.first = HLoc + RightStep;
7653 TrackMapKeyPair.second = VLoc;
7654 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7663 TrainPresent =
true;
7683 for(
unsigned int x = 0; x < SearchVector.size(); x++)
7700 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7703 throw Exception(
"PlotSmallFlashingLinkedLevelCrossings");
7709 while(
IsLCAtHV(61, HLoc, (VLoc + UpStep)))
7716 while(
IsLCAtHV(62, HLoc, (VLoc + DownStep)))
7722 for(
int x = UpStep; x <= DownStep; x++)
7729 while(
IsLCAtHV(63, (HLoc + LStep), VLoc))
7736 while(
IsLCAtHV(64, (HLoc + RStep), VLoc))
7742 for(
int x = LStep; x <= RStep; x++)
7758 throw Exception(
"Error, Wrong track type in GetFilletGraphic");
7765 else if(TrackElement.
SpeedTag < 132)
7783 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
7800 AnsiString(ScreenPosV));
7815 AnsiString(ScreenPosV));
7826 AnsiString(VPosTrue));
7840 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7852 throw Exception(
"CheckMapAndTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7853 " in TrackMap, Caller=" + (AnsiString)Caller);
7855 if(MapVecPos != (
int)a)
7857 throw Exception(
"CheckMapAndTrack Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7858 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)MapVecPos +
" TrackVectorPos value=" + (AnsiString)a +
" Caller=" +
7859 (AnsiString)Caller);
7865 throw Exception(
"CheckMapAndTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7866 " Caller=" + (AnsiString)Caller);
7886 throw Exception(
"CheckMapAndInactiveTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7887 " in InactiveMap, Caller=" + (AnsiString)Caller);
7889 if((InactivePair.first != a) && (InactivePair.second != a))
7891 throw Exception(
"CheckMapAndInactiveTrack Error - InactiveMapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7892 (AnsiString)CheckElement.
VLoc +
" Inactive Map values=" + (AnsiString)InactivePair.first +
" and " + (AnsiString)InactivePair.second +
7893 " InactiveTrackVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
7898 throw Exception(
"CheckMapAndInactiveTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7899 " Caller=" + (AnsiString)Caller);
7909 int Position1, Position2;
7915 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
7917 int HLoc1 = GapMapPtr->first.first;
7918 int VLoc1 = GapMapPtr->first.second;
7919 int HLoc2 = GapMapPtr->second.first;
7920 int VLoc2 = GapMapPtr->second.second;
7923 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
7927 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
7931 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
7935 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
7939 unsigned int GapCount = 0;
7941 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7949 if((
GapMap.size() * 2) != GapCount)
7951 throw Exception(
"GapMap Error - Map Size * 2 =" + (AnsiString)(
GapMap.size() * 2) +
" GapCount=" + (AnsiString)GapCount +
" Caller=" +
7952 (AnsiString)Caller);
7962 if((TrackElement.
HLoc == -2000000000) || (TrackElement.
VLoc == -2000000000))
7966 throw Exception(
"Error - TrackFinished with erase element still present");
7971 AnsiString IDString;
7973 if(TrackElement.
HLoc < 0)
7975 IDString =
"N" + AnsiString(abs(TrackElement.
HLoc)) +
"-";
7979 IDString = AnsiString(TrackElement.
HLoc) +
"-";
7981 if(TrackElement.
VLoc < 0)
7983 IDString +=
"N" + AnsiString(abs(TrackElement.
VLoc));
7987 IDString += AnsiString(TrackElement.
VLoc);
8002 for(
int x = 1; x < String.Length() + 1; x++)
8004 if(String.IsDelimiter(
"-", x))
8009 if(x == String.Length())
8013 ShowMessage(
"Error in track element identifier: <" + String +
"> - no delimiter");
8023 ShowMessage(
"Error in track element identifier: <" + String +
"> - No Horizontal value");
8028 if(DelimPos == String.Length())
8032 ShowMessage(
"Error in track element identifier <" + String +
"> - No Vertical value");
8037 if((String[String.Length()] <
'0') || (String[String.Length()] >
'9'))
8041 ShowMessage(
"Error in track element identifier <" + String +
"> - Last value is not a number");
8048 if(String.SubString(1, 1) !=
"N")
8050 for(
int x = 1; x < DelimPos; x++)
8052 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8056 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
8063 if(String.SubString(1, 1) ==
"N")
8065 for(
int x = 2; x < DelimPos; x++)
8067 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8071 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
8078 if(String.SubString(1, 1) ==
"N")
8080 HLoc = -(String.SubString(2, DelimPos - 2).ToInt());
8084 HLoc = String.SubString(1, DelimPos - 1).ToInt();
8086 if(String.SubString(DelimPos + 1, 1) !=
"N")
8088 for(
int x = DelimPos + 1; x < String.Length() + 1; x++)
8090 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8094 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
8101 if(String.SubString(DelimPos + 1, 1) ==
"N")
8103 for(
int x = DelimPos + 2; x < String.Length() + 1; x++)
8105 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8109 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
8116 if(String.SubString(DelimPos + 1, 1) ==
"N")
8118 VLoc = -(String.SubString(DelimPos + 2, String.Length() - DelimPos - 1).ToInt());
8122 VLoc = String.SubString(DelimPos + 1, String.Length() - DelimPos).ToInt();
8127 TrackMapPtr =
TrackMap.find(HVPair);
8132 ShowMessage(
"No track element corresponding to track element identifier: <" + String +
">");
8138 return(TrackMapPtr->second);
8140 catch(
const Exception &e)
8143 ShowMessage(
"Syntax error in track element identifier: <" + String +
">");
8157 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
8158 int HLoc = TrackElement.
HLoc;
8159 int VLoc = TrackElement.
VLoc;
8262 AnsiString(SpeedTag));
8273 if(HVRange.first == HVRange.second)
8280 HVIt1 = HVRange.first;
8285 if(--HVRange.second != HVRange.first)
8287 HVIt2 = HVRange.second;
8291 HVIt2->second).
SpeedTag == SpeedTag)))
8311 AnsiString(SpeedTag));
8377 AnsiString TestString1, TestString2;
8382 throw Exception(
"LNPendingList size not 1 on entry");
8384 int CurrentElementNumber;
8390 int H = CurrentElement->HLoc;
8391 int V = CurrentElement->VLoc;
8392 int Tag = CurrentElement->SpeedTag;
8398 for(
int x = 0; x < 25; x++)
8408 for(
int x = 0; x < 25; x++)
8418 for(
int x = 0; x < 25; x++)
8428 for(
int x = 0; x < 25; x++)
8438 for(
int x = 0; x < 28; x++)
8448 for(
int x = 0; x < 8; x++)
8458 for(
int x = 0; x < 8; x++)
8468 for(
int x = 0; x < 4; x++)
8478 for(
int x = 0; x < 8; x++)
8488 for(
int x = 0; x < 8; x++)
8501 if(CurrentElementNumber > -1)
8506 if((ExistingName !=
"") && (ExistingName != LocationName))
8522 AddName(1, CurrentElement, LocationName);
8526 LNDone2MultiMapEntry.first = HVPair;
8537 bool FoundFlag, ErasedFlag =
false;
8539 if(SNRange.first != SNRange.second)
8543 for(SNIterator = SNRange.second; SNIterator != SNRange.first; SNIterator--)
8550 TVIt->LocationName =
"";
8551 TVIt->ActiveTrackElementName =
"";
8584 std::pair<AnsiString, char>TempMapPair;
8592 TempMapPair.second =
'x';
8610 AnsiString(SpeedTag));
8620 if((SpeedTag == 129) || (SpeedTag == 130) || (SpeedTag == 145) || (SpeedTag == 146))
8627 int MapPos = -1 - Position;
8631 FoundElement = MapPos;
8647 FoundElement = IMPair.first;
8656 FoundElement = IMPair.second;
8677 AnsiString OldName = TrackElement->LocationName, ErrorString;
8679 TrackElement->LocationName = Name;
8680 int HLoc = TrackElement->HLoc;
8681 int VLoc = TrackElement->VLoc;
8695 if(ErrorString !=
"")
8697 throw Exception(ErrorString +
" in AddName for OldName == " + OldName);
8721 if(LNDone2MultiMapIterator->second == MapPos)
8748 if(*LNPendingListIterator == MapPos)
8821 if(NameBeingChecked !=
"")
8827 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8835 NameBeingChecked = LNMMRg.second->first;
8837 if(NameBeingChecked !=
"")
8843 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8864 if(LNMMIt->second < 0)
8874 HVPairsLinkedMap.insert(std::pair<THVPair, bool>(HVPair,
false));
8882 std::list<THVPair> HVLinkedList;
8885 HVPairsLinkedMap.begin()->second =
true;
8886 HVLinkedList.push_back(HVPairsLinkedMap.begin()->first);
8889 THVPair HVPairUnderExamination;
8890 THVPairsLinkedMap::iterator HVPLMIt;
8892 while(!HVLinkedList.empty())
8894 HVPairUnderExamination = HVLinkedList.front();
8895 HVLinkedList.pop_front();
8896 HVPairNew.first = HVPairUnderExamination.first;
8897 HVPairNew.second = HVPairUnderExamination.second - 1;
8898 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8899 if(HVPLMIt != HVPairsLinkedMap.end())
8901 if(!HVPLMIt->second)
8903 HVLinkedList.push_back(HVPLMIt->first);
8905 HVPLMIt->second =
true;
8907 HVPairNew.first = HVPairUnderExamination.first - 1;
8908 HVPairNew.second = HVPairUnderExamination.second;
8909 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8910 if(HVPLMIt != HVPairsLinkedMap.end())
8912 if(!HVPLMIt->second)
8914 HVLinkedList.push_back(HVPLMIt->first);
8916 HVPLMIt->second =
true;
8918 HVPairNew.first = HVPairUnderExamination.first;
8919 HVPairNew.second = HVPairUnderExamination.second + 1;
8920 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8921 if(HVPLMIt != HVPairsLinkedMap.end())
8923 if(!HVPLMIt->second)
8925 HVLinkedList.push_back(HVPLMIt->first);
8927 HVPLMIt->second =
true;
8929 HVPairNew.first = HVPairUnderExamination.first + 1;
8930 HVPairNew.second = HVPairUnderExamination.second;
8931 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8932 if(HVPLMIt != HVPairsLinkedMap.end())
8934 if(!HVPLMIt->second)
8936 HVLinkedList.push_back(HVPLMIt->first);
8938 HVPLMIt->second =
true;
8943 for(THVPairsLinkedMap::iterator HVPLMIt = HVPairsLinkedMap.begin(); HVPLMIt != HVPairsLinkedMap.end(); HVPLMIt++)
8945 if(!HVPLMIt->second)
8964 if(LocationName ==
"")
8975 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8982 ActiveTrackElementNameMapEntry.second = 0;
9004 bool FoundFlag, ErasedFlag =
false;
9008 if(SNRange.first != SNRange.second)
9011 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9014 TVIt->LocationName =
"";
9015 TVIt->ActiveTrackElementName =
"";
9049 AnsiString(VLoc) +
"," + AnsiString(SpeedTag));
9051 AnsiString LocationName;
9060 if(LocationName !=
"")
9068 if(LocationName !=
"")
9082 if(LocationName !=
"")
9084 int ModifiedPosition = -1 - Position;
9093 for(
int x = 0; x < 25; x++)
9103 else if(SpeedTag == 77)
9105 for(
int x = 0; x < 25; x++)
9115 else if(SpeedTag == 78)
9117 for(
int x = 0; x < 25; x++)
9127 else if(SpeedTag == 79)
9129 for(
int x = 0; x < 25; x++)
9139 else if(SpeedTag == 96)
9141 for(
int x = 0; x < 28; x++)
9151 else if(SpeedTag == 129)
9153 for(
int x = 0; x < 8; x++)
9163 else if(SpeedTag == 130)
9165 for(
int x = 0; x < 8; x++)
9175 else if(SpeedTag == 145)
9177 for(
int x = 0; x < 8; x++)
9187 else if(SpeedTag == 146)
9189 for(
int x = 0; x < 8; x++)
9199 else if(SpeedTag == 131)
9201 for(
int x = 0; x < 4; x++)
9224 AnsiString(SpeedTag));
9236 if(TempElement->LocationName !=
"")
9238 LocationName = TempElement->LocationName;
9239 FoundElement = IMPair.first;
9247 if(TempElement->LocationName !=
"")
9249 LocationName = TempElement->LocationName;
9250 FoundElement = IMPair.second;
9262 if(TempElement->LocationName !=
"")
9264 LocationName = TempElement->LocationName;
9265 FoundElement = -1 - Position;
9281 unsigned int Count = 0;
9288 AnsiString SName, TName, ErrorString;
9290 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9296 throw Exception(
"Track element has FixedNamedLocationElement set but is not a footbridge/underpass in CheckLocationNameMultiMap, caller = " +
9297 AnsiString(Caller));
9310 (
"Inactive track element has FixedNamedLocationElement set but is not a platform, concourse or named location in CheckLocationNameMultiMap, caller = " +
9311 AnsiString(Caller));
9318 throw Exception(
"LocationNameMultiMap size = " + AnsiString(
LocationNameMultiMap.size()) +
" & Count = " + AnsiString(Count) +
9319 " in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9324 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9330 if(ErrorString !=
"")
9332 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for TrackVector check, caller = " + AnsiString(Caller));
9334 if(SNIt->second != -1 - (
int)x)
9336 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9337 AnsiString(Caller));
9343 bool FoundFlag =
false;
9352 throw Exception(
"Track element with ActiveTrackElementName but no plat/named loc at H " + AnsiString(
TrackElementAt(1369, x).HLoc) +
" & V " +
9353 AnsiString(
TrackElementAt(1370, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9357 throw Exception(
"Track element with ActiveTrackElementName " + TName +
" but plat/named loc at H " + AnsiString(
TrackElementAt(1371, x).HLoc) +
9358 " & V " + AnsiString(
TrackElementAt(1372, x).VLoc) +
" has different LocationName in CheckLocationNameMultiMap, caller = " +
9359 AnsiString(Caller));
9364 throw Exception(
"Track element with ActiveTrackElementName but no inactive element at H " + AnsiString(
TrackElementAt(1373, x).HLoc) +
" & V " +
9365 AnsiString(
TrackElementAt(1374, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9375 if(ErrorString !=
"")
9377 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for InactiveTrackVector check, caller = " + AnsiString(Caller));
9379 if(SNIt->second != (
int)x)
9381 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9382 AnsiString(Caller));
9392 AnsiString &ErrorString)
9400 AnsiString(TrackElement->HLoc) +
"," + AnsiString(TrackElement->VLoc) +
"," + AnsiString(TrackElement->SpeedTag));
9402 bool FoundFlag =
false;
9406 if(SNRange.first == SNRange.second)
9408 ErrorString =
"Error, Name " + LocationName +
" not found in map";
9410 return(SNRange.first);
9414 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9416 if(SNIterator->second < 0)
9418 int TVPos = -1 - SNIterator->second;
9420 if(TVIt == TrackElement)
9429 int ITVPos = SNIterator->second;
9431 if(ITVIt == TrackElement)
9442 ErrorString =
"Error, Name " + LocationName +
" found but not at required element";
9459 LocationNameEntry.first = NewName;
9460 LocationNameEntry.second = SNIterator->second;
9474 int TruePos = -1 - Position;
9478 throw Exception(
"Footbridge/underpass error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9488 throw Exception(
"Inactive element error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9511 InactiveTrack2MultiMapIterator++)
9513 if(InactiveTrack2MultiMapIterator->second > VecPos)
9515 InactiveTrack2MultiMapIterator->second--;
9523 LocationNameMultiMapIterator++)
9525 if(LocationNameMultiMapIterator->second < 0)
9529 if(LocationNameMultiMapIterator->second > (
int)VecPos)
9531 LocationNameMultiMapIterator->second--;
9553 for(TrackMapIterator =
TrackMap.begin(); TrackMapIterator !=
TrackMap.end(); TrackMapIterator++)
9555 if(TrackMapIterator->second > VecPos)
9557 TrackMapIterator->second--;
9565 LocationNameMultiMapIterator++)
9567 if(LocationNameMultiMapIterator->second >= 0)
9573 if(LocationNameMultiMapIterator->second < -(
int)(VecPos + 1))
9575 LocationNameMultiMapIterator->second++;
9579 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9585 if(TkEl.
Conn[0] ==
int(VecPos))
9590 if(TkEl.
Conn[0] >
int(VecPos))
9594 if(TkEl.
Conn[0] > -1)
9620 for(
unsigned int TVPos = 0; TVPos <
TrackVector.size(); TVPos++)
9626 LocationNameEntry.second = -1 - TVPos;
9637 LocationNameEntry.second = ITVPos;
9679 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9711 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9739 AnsiString((
short)FirstTrack));
9740 bool LengthDifferent =
false, SpeedDifferent =
false;
9747 int EXArray[16][2] =
9749 {2, 4}, {6, 2}, {8, 6}, {4, 8},
9750 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
9753 int Index = -1, BrNum = -1, GrNum = -1, InLink, OutLink;
9754 Graphics::TBitmap *Bitmap;
9758 InLink = TrackElement.
Link[0];
9759 OutLink = TrackElement.
Link[1];
9763 InLink = TrackElement.
Link[2];
9764 OutLink = TrackElement.
Link[3];
9766 for(
int x = 0; x < 16; x++)
9768 if((InLink == EXArray[x][0] && OutLink == EXArray[x][1]) || (InLink == EXArray[x][1] && OutLink == EXArray[x][0]))
9775 throw Exception(
"Error, failed to find Index in TTrack::MarkOneLength");
9794 else if(TrackElement.
SpeedTag == 54)
9798 else if(TrackElement.
SpeedTag == 55)
9809 else if(TrackElement.
SpeedTag == 58)
9813 else if(TrackElement.
SpeedTag == 59)
9818 else if(Index == 14)
9824 else if(TrackElement.
SpeedTag == 52)
9828 else if(TrackElement.
SpeedTag == 57)
9833 else if(Index == 15)
9839 else if(TrackElement.
SpeedTag == 53)
9843 else if(TrackElement.
SpeedTag == 56)
9857 if(LengthDifferent && SpeedDifferent)
9925 else if(LengthDifferent && !SpeedDifferent)
10072 AnsiString((
short)FirstTrack));
10073 LengthDifferent =
false;
10074 SpeedDifferent =
false;
10079 LengthDifferent =
true;
10083 SpeedDifferent =
true;
10085 if(LengthDifferent || SpeedDifferent)
10098 LengthDifferent =
true;
10102 SpeedDifferent =
true;
10104 if(LengthDifferent || SpeedDifferent)
10117 LengthDifferent =
true;
10121 SpeedDifferent =
true;
10123 if(LengthDifferent || SpeedDifferent)
10203 AnsiString TempName;
10204 int VecPos, StartVecPos, Count, EntryPos, StartEntryPos, ForwardNumber, ReverseNumber;
10205 bool ForwardSet, ReverseSet;
10207 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10212 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10214 ForwardSet =
false;
10215 ReverseSet =
false;
10250 for(
int y = 0; y < 2; y++)
10281 StartElement = TempElement;
10282 StartVecPos = VecPos;
10285 EntryPos = 1 - Dir;
10286 StartEntryPos = 1 - Dir;
10295 VecPos = TempElement.
Conn[1 - EntryPos];
10296 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10298 EntryPos = TempEntryPos;
10326 ForwardNumber = ((Count + 1) / 2) + 1;
10327 ReverseNumber = (Count - ForwardNumber) + 1;
10329 EntryPos = 1 - Dir;
10330 TempElement = StartElement;
10331 VecPos = StartVecPos;
10332 if(Count == ForwardNumber)
10337 if(Count == ReverseNumber)
10345 VecPos = TempElement.
Conn[1 - EntryPos];
10346 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10348 EntryPos = TempEntryPos;
10350 if(Count == ForwardNumber)
10355 if(Count == ReverseNumber)
10367 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10503 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10559 if((TextH / 16) - 1 <
HLocMin)
10563 if((TextH / 16) + 1 >
HLocMax)
10567 if((TextV / 16) - 1 <
VLocMin)
10571 if((TextV / 16) + 1 >
VLocMax)
10601 void TTrack::UserGraphicMove(
int Caller,
int HPosInput,
int VPosInput,
int &UserGraphicItem,
int &UserGraphicMoveHPos,
int &UserGraphicMoveVPos,
10602 bool &UserGraphicFoundFlag)
10605 TUserGraphicVector::iterator UserGraphicPtr;
10607 UserGraphicFoundFlag =
false;
10614 if((HPosInput >= (*UserGraphicPtr).HPos) && (HPosInput < ((*UserGraphicPtr).HPos + (*UserGraphicPtr).Width)) && (VPosInput >=
10615 (*UserGraphicPtr).VPos) && (VPosInput < ((*UserGraphicPtr).VPos + (*UserGraphicPtr).Height)))
10617 UserGraphicItem = x;
10618 UserGraphicMoveHPos = (*UserGraphicPtr).HPos;
10619 UserGraphicMoveVPos = (*UserGraphicPtr).VPos;
10620 UserGraphicFoundFlag =
true;
10638 int SpeedTag = TrackElement.
SpeedTag;
10642 throw Exception(
"Error - SpeedTag value " + AnsiString(SpeedTag) +
" in RetrieveStripedNamedLocationGraphicsWhereRelevant");
10691 return(GraphicOutput);
10699 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10702 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in TrackElementAt");
10715 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
InactiveTrackVector.size()) +
", At: " + AnsiString(At) +
10716 " in InactiveTrackElementAt");
10727 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10729 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in BlankElementAt");
10754 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
10755 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
10759 if(SNRange.first == SNRange.second)
10764 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10766 if(SNIterator->second < 0)
10780 HVPair.first = InactiveElement.
HLoc;
10781 HVPair.second = InactiveElement.
VLoc;
10785 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneNamedLocationLongEnoughForSplit (1)");
10787 int TVPos =
TrackMap.find(HVPair)->second;
10790 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
10796 FirstNamedExitPos = 0;
10798 SecondNamedElement =
TrackElementAt(561, FirstNamedElement.
Conn[FirstNamedExitPos]);
10800 FirstNamedLinkedElement =
TrackElementAt(562, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10801 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10804 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10806 SecondNamedLinkedElement =
TrackElementAt(563, SecondNamedElement.
Conn[SecondNamedExitPos]);
10807 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10808 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10811 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10821 FirstNamedExitPos = 1;
10823 SecondNamedElement =
TrackElementAt(564, FirstNamedElement.
Conn[FirstNamedExitPos]);
10825 FirstNamedLinkedElement =
TrackElementAt(565, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10826 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10829 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10831 SecondNamedLinkedElement =
TrackElementAt(566, SecondNamedElement.
Conn[SecondNamedExitPos]);
10832 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10833 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10836 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10852 int &FirstNamedLinkedElementPos,
int &SecondNamedLinkedElementPos)
10866 AnsiString(FirstNamedElementPos));
10867 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
10868 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
10870 SecondNamedElementPos = -1;
10871 FirstNamedLinkedElementPos = -1;
10872 SecondNamedLinkedElementPos = -1;
10876 if(SNRange.first == SNRange.second)
10881 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10883 if(SNIterator->second < 0)
10893 HVPair.first = InactiveElement.
HLoc;
10894 HVPair.second = InactiveElement.
VLoc;
10906 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in ThisNamedLocationLongEnoughForSplit (2)"
10910 int TVPos =
TrackMap.find(HVPair)->second;
10911 if(TVPos != FirstNamedElementPos)
10917 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
10923 FirstNamedExitPos = 0;
10925 SecondNamedElement =
TrackElementAt(568, FirstNamedElement.
Conn[FirstNamedExitPos]);
10927 FirstNamedLinkedElement =
TrackElementAt(569, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10928 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10931 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10933 SecondNamedLinkedElement =
TrackElementAt(570, SecondNamedElement.
Conn[SecondNamedExitPos]);
10934 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10935 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10938 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10940 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
10941 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
10942 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
10951 FirstNamedExitPos = 1;
10953 SecondNamedElement =
TrackElementAt(571, FirstNamedElement.
Conn[FirstNamedExitPos]);
10955 FirstNamedLinkedElement =
TrackElementAt(572, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10956 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10959 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10961 SecondNamedLinkedElement =
TrackElementAt(573, SecondNamedElement.
Conn[SecondNamedExitPos]);
10962 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10963 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10966 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10968 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
10969 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
10970 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
10991 if(SNRange.first != SNRange.second)
10993 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10995 if(SNIterator->second < 0)
11017 "," + AnsiString(SpeedTag));
11028 throw Exception(
"Error, FoundFlag false in PlatformOnSignalSide after IsPlatformOrNamedNonStationLocationPresent called successfully");
11058 else if(SpeedTag == 69)
11084 else if(SpeedTag == 70)
11110 else if(SpeedTag == 71)
11147 AnsiString(NextEntryPos) +
"," + AnsiString(OwnTrainID));
11148 if(NextEntryPos < 0)
11161 if(NextEntryPos > 1)
11180 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in SelectVectorAt");
11192 AnsiString(VLocIn) +
"," + AnsiString(LinkIn));
11193 bool FoundFlag =
false;
11208 int VLocHi = -2000000000, VLocLo = 2000000000, HLoc = 2000000000;
11209 bool FoundFlag =
false;
11234 VPosHi = 16 * VLocHi;
11235 VPosLo = 16 * VLocLo;
11254 AnsiString(EndTVPosition));
11265 int Link0Squares = ((EndElement.
HLoc - NewHLocLink0) * (EndElement.
HLoc - NewHLocLink0)) +
11266 ((EndElement.
VLoc - NewVLocLink0) * (EndElement.
VLoc - NewVLocLink0));
11267 int Link1Squares = ((EndElement.
HLoc - NewHLocLink1) * (EndElement.
HLoc - NewHLocLink1)) +
11268 ((EndElement.
VLoc - NewVLocLink1) * (EndElement.
VLoc - NewVLocLink1));
11270 if(Link0Squares <= Link1Squares)
11288 AnsiString(LinkPos));
11307 if((LinkPos == 1) && (TE.
Attribute == 0))
11312 else if(LinkPos == 1)
11318 else if((LinkPos == 3) && (TE.
Attribute == 1))
11323 else if(LinkPos == 3)
11330 else if(LinkPos == 0)
11335 else if(LinkPos == 1)
11340 else if(LinkPos == 2)
11345 else if(LinkPos == 3)
11350 throw Exception(
"Error, failure in GetExitPos");
11399 if((TE.
Link[0] == Link) || (TE.
Link[1] == Link))
11403 else if((TE.
Link[2] == Link) || (TE.
Link[3] == Link))
11445 "," + AnsiString(DiagonalLinkNumber));
11450 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(8, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
TrainOnLink(9, HLoc - 1, VLoc, 9, TrainID)))
11455 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(10, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
TrainOnLink(11, HLoc, VLoc - 1, 9, TrainID)))
11460 if(((DiagonalLinkNumber == 3) &&
TrainOnLink(12, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(13, HLoc + 1, VLoc, 7, TrainID)))
11465 if(((DiagonalLinkNumber == 7) &&
TrainOnLink(14, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(15, HLoc, VLoc + 1, 3, TrainID)))
11481 AnsiString JustFileName =
"";
11486 int LastDelim = UGI.
FileName.LastDelimiter(
'\\');
11493 JustFileName = UGI.
FileName.SubString(LastDelim + 1, UGI.
FileName.Length() - LastDelim);
11512 typedef std::list<int> TNamePosList;
11513 TNamePosList NamePosList;
11514 typedef TNamePosList::iterator TNPLIt;
11516 typedef std::list<int> TOnePlatList;
11517 TOnePlatList OnePlatList;
11518 typedef TOnePlatList::iterator TOPLIt;
11521 NamePosList.clear();
11522 OnePlatList.clear();
11523 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
11525 if(
TrackElementAt(988, x).ActiveTrackElementName == LocationName)
11527 NamePosList.push_back(x);
11532 if(!NamePosList.empty())
11534 OnePlatList.push_back(NamePosList.back());
11535 NamePosList.pop_back();
11537 while(!OnePlatList.empty())
11539 TempInt = OnePlatList.front();
11542 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[0]);
11543 if(NPLIt != NamePosList.end() && ((TempElement.
Link[0] == 2) || (TempElement.
Link[0] == 4) || (TempElement.
Link[0] == 6) || (TempElement.
Link[0] == 8)))
11545 OnePlatList.push_back(TempElement.
Conn[0]);
11546 NamePosList.erase(NPLIt);
11548 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[1]);
11549 if(NPLIt != NamePosList.end() && ((TempElement.
Link[1] == 2) || (TempElement.
Link[1] == 4) || (TempElement.
Link[1] == 6) || (TempElement.
Link[1] == 8)))
11551 OnePlatList.push_back(TempElement.
Conn[1]);
11552 NamePosList.erase(NPLIt);
11555 OnePlatList.erase(OnePlatList.begin());
11556 if(OnePlatList.empty())
11559 if(!NamePosList.empty())
11561 OnePlatList.push_back(NamePosList.back());
11562 NamePosList.pop_back();
11578 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not signal in RepairFailedSignals");
11582 throw Exception(
"Signals not failed at " + AnsiString(FPVIt->TVPos) +
" in RepairFailedSignals");
11610 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not points in RepairFailedPoints");
11614 throw Exception(
"Points not failed at " + AnsiString(FPVIt->TVPos) +
" in RepairFailedPoints");
11640 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not simple in RepairFailedPoints");
11644 throw Exception(
"No TSR at " + AnsiString(FPVIt->TVPos) +
" in RepairTSR");
11666 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
11685 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
UserGraphicVector.size()) +
", At: " + AnsiString(At) +
" in UserGraphicVectorAt");
11700 throw Exception(
"Return value negative in call to LastElementNumber");
11712 throw Exception(
"PrefDirVector empty in call to LastElementPtr");
11726 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedPrefDirElementAt");
11738 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
11739 " in GetModifiablePrefDirElementAt");
11749 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
11751 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedSearchElementAt");
11761 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
11763 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableSearchElementAt");
11780 int TrackVectorPosition;
11831 FinishElement =
false;
11832 int TrackVectorPosition;
11854 if(TrackElement.
HLoc >= StartPrefDirElement.
HLoc)
11864 if(TrackElement.
VLoc >= StartPrefDirElement.
VLoc)
11887 for(
int x = 0; x < 4; x++)
11910 FinishElement =
true;
11918 for(
int x = 0; x < 4; x++)
11930 FinishElement =
true;
11938 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
11945 .ELinkPos] ==
Lead))
11961 FinishElement =
true;
11980 FinishElement =
true;
11999 FinishElement =
true;
12014 FinishElement =
true;
12023 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12039 FinishElement =
true;
12045 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12068 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition));
12069 int VectorCount = 0;
12073 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
12075 for(
int x = 0; x < VectorCount; x++)
12082 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
12086 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
12087 SearchElement.
ELinkPos = NextELinkPos;
12108 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
12110 SearchElement.
XLinkPos = NextXLinkPos;
12136 for(
int x = 0; x < VectorCount; x++)
12148 for(
int x = 0; x < VectorCount; x++)
12162 for(
int x = 0; x < VectorCount; x++)
12176 for(
int x = 0; x < VectorCount; x++)
12186 for(
int x = 0; x < VectorCount; x++)
12197 SearchElement.
XLink = SearchElement.
Link[1];
12216 SearchElement.
XLink = SearchElement.
Link[3];
12229 for(
int x = 0; x < VectorCount; x++)
12244 XLinkPos = NextXLinkPos;
12245 CurrentTrackElement = SearchElement;
12264 throw Exception(
"Error, SearchVector empty");
12271 for(
int x = 0; x < 4; x++)
12324 throw Exception(
"Error in EntryExitNumber 1");
12343 if(PrefDirElement.
XLink == -1)
12355 if(PrefDirElement.
XLink != -1)
12359 throw Exception(
"Error in EntryExitNumber 2");
12397 LeadingPoints =
false;
12425 LeadingPoints =
true;
12441 AnsiString ErrorString;
12442 bool Error =
false;
12449 ErrorString =
"HLoc";
12455 ErrorString =
"VLoc";
12461 ErrorString =
"ELink";
12467 ErrorString =
"ELinkPos";
12473 ErrorString =
"XLink";
12479 ErrorString =
"XLinkPos";
12485 ErrorString =
"Tag";
12491 ErrorString =
"TrackVectorPosition";
12497 ErrorString =
"EXNumber";
12504 ErrorString =
"CheckCount";
12511 ErrorString =
"EntryGraphicPtr";
12517 ErrorString =
"EntryDirectionGraphicPtr";
12526 ErrorString =
"Last XLink not connected to this element";
12533 throw Exception(
"Error at " + AnsiString(Position) +
" " + ErrorString);
12557 for(
int PrefDirVecPos = (
PrefDirVector.size() - 1); PrefDirVecPos >= (int)x; PrefDirVecPos--)
12614 AnsiString((
short)BuildingPrefDir));
12617 if(PrefDirSize() == 0)
12622 for(
unsigned int x = 0; x < PrefDirSize(); x++)
12634 Disp->PlotOutput(12, (TempPrefDirElement.
HLoc * 16), (TempPrefDirElement.
VLoc * 16), TempPrefDirElement.
EXGraphicPtr);
12646 if(x == (PrefDirSize() - 1))
12655 if((PrefDirRoute ==
PrefDirCall) && BuildingPrefDir)
12657 HPos = GetFixedPrefDirElementAt(4, 0).
HLoc * 16;
12658 VPos = GetFixedPrefDirElementAt(5, 0).VLoc * 16;
12659 Disp->Rectangle(1, HPos, VPos,
clB0G0R5, 2, 2);
12661 if(PrefDirSize() > 1)
12663 unsigned int LatestPos = PrefDirSize() - 1;
12664 HPos = GetFixedPrefDirElementAt(6, LatestPos).HLoc * 16;
12665 VPos = GetFixedPrefDirElementAt(7, LatestPos).VLoc * 16;
12666 Disp->Rectangle(2, HPos, VPos,
clB5G0R0, 4, 2);
12687 int H, V, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12690 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
12694 H = MMIT->first.first;
12695 V = MMIT->first.second;
12698 if(PrefDirPos0 > -1)
12702 if(PrefDirPos1 > -1)
12706 if(PrefDirPos2 > -1)
12710 if(PrefDirPos3 > -1)
12714 if(PrefDirPos3 > -1)
12730 else if(PrefDirPos2 > -1)
12772 else if(PrefDirPos1 > -1)
12795 else if(PrefDirPos0 > -1)
12814 int NumberOfPrefDirElements = 0;
12817 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12819 VecFile >> TempInt;
12822 VecFile >> TempInt;
12823 LoadPrefDirElement.
ELink = TempInt;
12824 VecFile >> TempInt;
12825 LoadPrefDirElement.
ELinkPos = TempInt;
12826 VecFile >> TempInt;
12827 LoadPrefDirElement.
XLink = TempInt;
12828 VecFile >> TempInt;
12829 LoadPrefDirElement.
XLinkPos = TempInt;
12830 VecFile >> TempInt;
12831 LoadPrefDirElement.
EXNumber = TempInt;
12832 VecFile >> TempInt;
12837 if(!(LoadPrefDirElement.
IsARoute))
12863 int NumberOfPrefDirElements = 0;
12866 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12868 VecFile >> TempInt;
12869 VecFile >> TempInt;
12872 VecFile >> TempInt;
12873 LoadPrefDirElement.
ELink = TempInt;
12874 VecFile >> TempInt;
12875 LoadPrefDirElement.
ELinkPos = TempInt;
12876 VecFile >> TempInt;
12877 LoadPrefDirElement.
XLink = TempInt;
12878 VecFile >> TempInt;
12879 LoadPrefDirElement.
XLinkPos = TempInt;
12880 VecFile >> TempInt;
12881 LoadPrefDirElement.
EXNumber = TempInt;
12882 VecFile >> TempInt;
12887 if(!(LoadPrefDirElement.
IsARoute))
12915 int NumberOfPrefDirElements = 0;
12918 if((NumberOfPrefDirElements < 0) || (NumberOfPrefDirElements > 1000000))
12923 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12930 VecFile >> TempInt;
12931 if((TempInt < 0) || (TempInt >= NumberOfActiveElements))
12936 VecFile >> TempInt;
12937 if((TempInt < -1) || (TempInt > 9))
12942 VecFile >> TempInt;
12943 if((TempInt < -1) || (TempInt > 3))
12948 VecFile >> TempInt;
12949 if((TempInt < -1) || (TempInt > 9))
12954 VecFile >> TempInt;
12955 if((TempInt < -1) || (TempInt > 3))
12960 VecFile >> TempInt;
12961 if((TempInt < -1) || (TempInt > 27))
12966 VecFile >> TempInt;
12974 VecFile >> TempInt;
12975 if((TempInt != 0) && (TempInt != 1))
12980 VecFile >> TempInt;
12981 if((TempInt != 0) && (TempInt != 1))
12986 VecFile >> TempInt;
12987 if((TempInt != 0) && (TempInt != 1))
13010 for(
int y = 0; y < NumberOfPrefDirElements; y++)
13012 VecFile << y <<
'\n';
13013 VecFile <<
PrefDirVector.at(y).TrackVectorPosition <<
'\n';
13023 if(y == (NumberOfPrefDirElements - 1))
13025 VecFile <<
"************" <<
'\0' <<
'\n';
13029 VecFile <<
"******" <<
'\0' <<
'\n';
13043 for(
int y = 0; y < NumberOfSearchElements; y++)
13045 VecFile << y <<
'\n';
13046 VecFile <<
SearchVector.at(y).TrackVectorPosition <<
'\n';
13056 if(y == (NumberOfSearchElements - 1))
13058 VecFile <<
"************" <<
'\0' <<
'\n';
13062 VecFile <<
"******" <<
'\0' <<
'\n';
13175 bool AlreadyPresent, FoundFlag;
13176 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13178 for(
unsigned int x = 0; x < InputPrefDir->
PrefDirSize(); x++)
13182 AlreadyPresent =
false;
13187 AlreadyPresent =
true;
13191 AlreadyPresent =
true;
13195 AlreadyPresent =
true;
13199 AlreadyPresent =
true;
13202 if(!AlreadyPresent)
13249 for(
unsigned int z = 0; z < 4; z++)
13257 throw Exception(
"Error in RebuildPrefDirVector - PrefDirVector is unsafe");
13271 bool DiscrepancyFound =
false;
13282 DiscrepancyFound =
true;
13287 DiscrepancyFound =
true;
13292 DiscrepancyFound =
true;
13297 DiscrepancyFound =
true;
13302 DiscrepancyFound =
true;
13308 DiscrepancyFound =
true;
13311 if(DiscrepancyFound)
13313 ShowMessage(
"Discrepancies found in the preferred direction file, preferred directions will be cleared");
13328 bool DiscrepancyFound =
false;
13339 DiscrepancyFound =
true;
13343 DiscrepancyFound =
true;
13348 DiscrepancyFound =
true;
13353 DiscrepancyFound =
true;
13358 DiscrepancyFound =
true;
13364 DiscrepancyFound =
true;
13368 return(!DiscrepancyFound);
13380 bool FoundFlag =
false;
13381 int PrefDir0, PrefDir1, PrefDir2, PrefDir3;
13389 throw Exception(
"CheckPrefDir4MultiMap Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
13390 " in PrefDir4MultiMap, Caller=" + (AnsiString)Caller);
13392 if((PrefDir0 != (
int)a) && (PrefDir1 != (
int)a) && (PrefDir2 != (
int)a) && (PrefDir3 != (
int)a))
13394 throw Exception(
"CheckPrefDir4MultiMap Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
13395 (AnsiString)CheckElement.
VLoc +
" Map values=" + (AnsiString)PrefDir0 +
", " + (AnsiString)PrefDir1 +
", " + (AnsiString)PrefDir2 +
", " +
13396 (AnsiString)PrefDir3 +
" PrefDirVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
13401 throw Exception(
"CheckPrefDir4MultiMap Error - Map Size=" + (AnsiString)
PrefDirVector.size() +
" PrefDirVectorSize=" + (AnsiString)
PrefDirVector.size()
13402 +
" Caller=" + (AnsiString)Caller);
13428 PrefDirMapKeyPair.first = HLoc;
13429 PrefDirMapKeyPair.second = VLoc;
13430 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13433 if(ItPair.first == ItPair.second)
13441 PrefDirPos0 = ItPair.first->second;
13443 if(ItPair.first == ItPair.second)
13448 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13450 PrefDirPos1 = ItPair.first->second;
13453 if(ItPair.first == ItPair.second)
13458 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13460 PrefDirPos2 = ItPair.first->second;
13463 if(ItPair.first == ItPair.second)
13468 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13470 PrefDirPos3 = ItPair.first->second;
13485 +
"," + AnsiString(LinkNumberPos));
13487 int PD0, PD1, PD2, PD3;
13488 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
13492 PD0, PD1, PD2, PD3);
13504 LinkedPrefDirVectorNumber = PD0;
13513 LinkedPrefDirVectorNumber = PD1;
13523 LinkedPrefDirVectorNumber = PD0;
13532 LinkedPrefDirVectorNumber = PD1;
13541 LinkedPrefDirVectorNumber = PD2;
13550 LinkedPrefDirVectorNumber = PD3;
13555 LinkedPrefDirVectorNumber = -1;
13561 LinkedPrefDirVectorNumber = -1;
13566 catch(
const Exception &e)
13568 LinkedPrefDirVectorNumber = -1;
13583 +
"," + AnsiString(LinkNumberPos));
13585 int PD0, PD1, PD2, PD3;
13586 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
13590 PD0, PD1, PD2, PD3);
13603 LinkedPrefDirVectorNumber = PD0;
13613 LinkedPrefDirVectorNumber = PD1;
13618 LinkedPrefDirVectorNumber = -1;
13626 LinkedPrefDirVectorNumber = PD0;
13635 LinkedPrefDirVectorNumber = PD1;
13644 LinkedPrefDirVectorNumber = PD2;
13653 LinkedPrefDirVectorNumber = PD3;
13658 LinkedPrefDirVectorNumber = -1;
13664 LinkedPrefDirVectorNumber = -1;
13669 catch(
const Exception &e)
13671 LinkedPrefDirVectorNumber = -1;
13683 int PD0, PD1, PD2, PD3;
13735 THVPair PrefDir4MultiMapKeyPair;
13738 PrefDir4MultiMapKeyPair.first = LoadPrefDirElement.
HLoc;
13739 PrefDir4MultiMapKeyPair.second = LoadPrefDirElement.
VLoc;
13740 PrefDir4MultiMapEntry.first = PrefDir4MultiMapKeyPair;
13763 throw Exception(
"Failed to find PrefDir4MultiMap erase element");
13782 AnsiString(ErasedElementNumber));
13787 if(MapPtr->second > ErasedElementNumber)
13809 throw Exception(
"PrefDirVectorPosition out of range");
13812 THVPair PrefDir4MultiMapKeyPair;
13814 PrefDir4MultiMapKeyPair.first = PrefDirElement.
HLoc;
13815 PrefDir4MultiMapKeyPair.second = PrefDirElement.
VLoc;
13816 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13819 if(ItPair.first == ItPair.second)
13822 return(ItPair.first);
13826 if(ItPair.first->second == PrefDirVectorPosition)
13830 return(ItPair.first);
13833 if(ItPair.first == ItPair.second)
13836 return(ItPair.first);
13838 if(ItPair.first->second == PrefDirVectorPosition)
13842 return(ItPair.first);
13845 if(ItPair.first == ItPair.second)
13848 return(ItPair.first);
13850 if(ItPair.first->second == PrefDirVectorPosition)
13854 return(ItPair.first);
13857 if(ItPair.first == ItPair.second)
13860 return(ItPair.first);
13862 if(ItPair.first->second == PrefDirVectorPosition)
13866 return(ItPair.first);
13870 return(ItPair.first);
13883 THVPair PrefDir4MultiMapKeyPair;
13885 PrefDir4MultiMapKeyPair.first = HLoc;
13886 PrefDir4MultiMapKeyPair.second = VLoc;
13887 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13890 if(ItPair.first == ItPair.second)
13898 return(ItPair.first->second);
13907 bool ErasedFlag =
false;
13909 if(ErasedTrackVectorPosition > -1)
13918 ErasedFlag =
false;
13920 if(
PrefDirVector.at(x).TrackVectorPosition == ErasedTrackVectorPosition)
13925 else if(
PrefDirVector.at(x).Conn[0] == ErasedTrackVectorPosition)
13930 else if(
PrefDirVector.at(x).Conn[1] == ErasedTrackVectorPosition)
13935 else if(
PrefDirVector.at(x).Conn[2] == ErasedTrackVectorPosition)
13940 else if(
PrefDirVector.at(x).Conn[3] == ErasedTrackVectorPosition)
13948 if(
PrefDirVector.at(x).TrackVectorPosition > ErasedTrackVectorPosition)
13952 if(
PrefDirVector.at(x).Conn[0] > ErasedTrackVectorPosition)
13956 if(
PrefDirVector.at(x).Conn[1] > ErasedTrackVectorPosition)
13960 if(
PrefDirVector.at(x).Conn[2] > ErasedTrackVectorPosition)
13964 if(
PrefDirVector.at(x).Conn[3] > ErasedTrackVectorPosition)
13979 OverallDistance = 0;
13980 OverallSpeedLimit = 0;
13981 LeadingPointsAtLastElement =
false;
13989 LeadingPointsAtLastElement =
true;
13998 OverallDistance += PrefDirElement.
Length23;
13999 if(OverallSpeedLimit != -1)
14009 OverallSpeedLimit = -1;
14016 OverallDistance += PrefDirElement.
Length01;
14017 if(OverallSpeedLimit != -1)
14027 OverallSpeedLimit = -1;
14046 int H, V, HLoc, VLoc, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14049 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
14053 HLoc = MMIT->first.first;
14054 VLoc = MMIT->first.second;
14059 if(PrefDirPos0 > -1)
14063 if(PrefDirPos1 > -1)
14067 if(PrefDirPos2 > -1)
14071 if(PrefDirPos3 > -1)
14075 if(PrefDirPos3 > -1)
14078 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14080 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14082 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14084 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement3.
GetRouteGraphicPtr(
false,
true));
14091 else if(PrefDirPos2 > -1)
14096 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14098 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14100 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
false));
14109 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14111 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14113 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
14122 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14124 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14126 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14133 else if(PrefDirPos1 > -1)
14138 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14140 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14148 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14150 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
14156 else if(PrefDirPos0 > -1)
14158 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14175 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14178 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
14200 if(PrefDirPos0 > -1)
14204 if(PrefDirPos1 > -1)
14208 if(PrefDirPos2 > -1)
14212 if(PrefDirPos3 > -1)
14216 if(PrefDirPos3 > -1)
14221 else if(PrefDirPos2 > -1)
14223 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos) || (PrefDirElement2.
XLinkPos == EntryPos))
14234 else if(PrefDirPos1 > -1)
14236 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos))
14247 else if(PrefDirPos0 > -1)
14249 if(PrefDirElement0.
XLinkPos == EntryPos)
14286 ElementIn.
VLoc +
"," + XLink);
14288 bool TrackFoundFlag;
14291 if((XLink == 2) || (XLink == 4) || (XLink == 6) || (XLink == 8))
14303 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
14313 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
14327 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
14337 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
14351 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
14361 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
14375 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
14385 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
14408 bool FoundFlag, ContFlag, FoundElements =
false;
14409 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14414 LastIteratorValue++;
14440 if(PDVIt->XLinkPos == 0)
14445 StartElement = *PDVIt;
14454 int NextTrackVectorPosition = PDVIt->
Conn[PDVIt->GetXLinkPos()];
14456 Track->
TrackElementAt(879, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14457 if(PrefDirPos0 == -1)
14461 bool NextElementFoundFlag =
false;
14465 NextElementFoundFlag =
true;
14467 if(PrefDirPos1 > -1)
14472 NextElementFoundFlag =
true;
14475 if(PrefDirPos2 > -1)
14480 NextElementFoundFlag =
true;
14483 if(PrefDirPos3 > -1)
14488 NextElementFoundFlag =
true;
14491 if(!NextElementFoundFlag)
14521 EndElement = NextElement;
14525 NextTrackVectorPosition = NextElement.
Conn[NextElement.
GetXLinkPos()];
14527 Track->
TrackElementAt(881, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14528 if(PrefDirPos0 == -1)
14538 if(PrefDirPos1 > -1)
14546 if(PrefDirPos2 > -1)
14554 if(PrefDirPos3 > -1)
14585 FoundElements =
true;
14619 AnsiString(VLoc) +
"," + AnsiString((
short)AutoSigsFlag));
14621 int TrackVectorPosition;
14657 int LockedVectorNumber;
14680 bool InPrefDirFlag =
false;
14683 int PrefDirPos0 = -1;
14684 int PrefDirPos1 = -1;
14685 int PrefDirPos2 = -1;
14686 int PrefDirPos3 = -1;
14690 int PrefDirVecPos[4] =
14692 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
14695 for(
int x = 0; x < 4; x++)
14697 int b = PrefDirVecPos[x];
14707 InPrefDirFlag =
true;
14720 TrainController->
StopTTClockMessage(12,
"Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
14728 if(DummyPair.first > -1)
14730 throw Exception(
"Selection in two routes - should never happen!");
14732 if(RoutePair.first > -1)
14808 IDInt &ReqPosRouteID,
bool &PointsChanged)
14842 AnsiString(VLoc) +
"," + AnsiString((
short)ConsecSignals) +
"," + AnsiString((
short)AutoSigsFlag));
14844 int NewFailedPointsTVPos = -1;
14893 bool InPrefDirFlag =
false;
14896 int PrefDirPos0 = -1;
14897 int PrefDirPos1 = -1;
14898 int PrefDirPos2 = -1;
14899 int PrefDirPos3 = -1;
14902 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14903 int PrefDirVecPos[4] =
14905 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
14908 for(
int x = 0; x < 4; x++)
14910 int b = PrefDirVecPos[x];
14913 InPrefDirFlag =
true;
14926 TrainController->
StopTTClockMessage(23,
"Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
14935 if(RoutePair.first > -1)
14937 if(RoutePair.second != 0)
14954 EndElement1 = RouteElement;
14955 EndElement2 = BlankElement;
15050 AutoSigsFlag,
false))
15055 if(NewFailedPointsTVPos > -1)
15059 " failed during route setting.");
15063 PointsChanged =
true;
15086 AutoSigsFlag,
false))
15091 if(NewFailedPointsTVPos > -1)
15095 " failed during route setting.");
15099 PointsChanged =
true;
15117 AutoSigsFlag,
false))
15122 if(NewFailedPointsTVPos > -1)
15126 " failed during route setting.");
15130 PointsChanged =
true;
15154 AutoSigsFlag,
false))
15159 if(NewFailedPointsTVPos > -1)
15163 " failed during route setting.");
15167 PointsChanged =
true;
15176 AutoSigsFlag,
false))
15181 if(NewFailedPointsTVPos > -1)
15185 " failed during route setting.");
15189 PointsChanged =
true;
15200 AutoSigsFlag,
false))
15205 if(NewFailedPointsTVPos > -1)
15209 " failed during route setting.");
15213 PointsChanged =
true;
15219 AutoSigsFlag,
false))
15224 if(NewFailedPointsTVPos > -1)
15228 " failed during route setting.");
15232 PointsChanged =
true;
15243 AutoSigsFlag,
false))
15248 if(NewFailedPointsTVPos > -1)
15252 " failed during route setting.");
15256 PointsChanged =
true;
15310 TOnePrefDir *EveryPrefDir,
bool ConsecSignals,
int EndPosition,
bool AutoSigsFlag,
bool RecursiveCall)
15362 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString(
ReqPosRouteID.
GetInt()) +
"," + AnsiString(EndPosition) +
"," +
15363 AnsiString((
short)AutoSigsFlag) +
"," + AnsiString((
short)RecursiveCall));
15364 int VectorCount = 0;
15372 if((PrefDirElement.
XLink == 1) || (PrefDirElement.
XLink == 3) || (PrefDirElement.
XLink == 7) || (PrefDirElement.
XLink == 9))
15376 for(
int x = 0; x < VectorCount; x++)
15384 bool FirstPass =
true;
15394 for(
int x = 0; x < VectorCount; x++)
15403 for(
int x = 0; x < VectorCount; x++)
15415 for(
int x = 0; x < VectorCount; x++)
15423 int NextPosition = PrefDirElement.
Conn[XLinkPos];
15427 int NextELinkPos = PrefDirElement.
ConnLinkPos[XLinkPos];
15428 SearchElement.
ELinkPos = NextELinkPos;
15429 SearchElement.
ELink = SearchElement.
Link[NextELinkPos];
15450 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
15452 SearchElement.
XLinkPos = NextXLinkPos;
15465 for(
int x = 0; x < VectorCount; x++)
15479 if(RoutePair.first > -1)
15488 for(
int x = 0; x < VectorCount; x++)
15497 if(SecondPair.first > -1)
15506 for(
int x = 0; x < VectorCount; x++)
15520 for(
int x = 0; x < VectorCount; x++)
15531 for(
int x = 0; x < VectorCount; x++)
15540 for(
int x = 0; x < VectorCount; x++)
15549 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15553 for(
int x = 0; x < VectorCount; x++)
15563 bool InPrefDirFlag =
false;
15564 PrefDirElement1 = BlankElement;
15565 PrefDirElement2 = BlankElement;
15568 int PrefDirPos0 = -1;
15569 int PrefDirPos1 = -1;
15570 int PrefDirPos2 = -1;
15571 int PrefDirPos3 = -1;
15574 int PrefDirVecPos[4] =
15576 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
15578 for(
int x = 0; x < 4; x++)
15580 int b = PrefDirVecPos[x];
15583 InPrefDirFlag =
true;
15596 for(
int x = 0; x < VectorCount; x++)
15608 for(
int x = 0; x < VectorCount; x++)
15624 for(
int x = 0; x < VectorCount; x++)
15635 for(
int x = 0; x < VectorCount; x++)
15655 for(
int x = 0; x < VectorCount; x++)
15668 for(
int x = 0; x < VectorCount; x++)
15682 for(
int x = 0; x < VectorCount; x++)
15692 for(
int x = 0; x < VectorCount; x++)
15723 for(
int x = 0; x < VectorCount; x++)
15732 for(
int x = 0; x < VectorCount; x++)
15744 int SearchPos1 = SearchElement.
Attribute + 1;
15746 if(SearchPos1 == 2)
15750 if(SearchPos1 == 1)
15758 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
15759 SearchElement.
XLinkPos = SearchPos1;
15760 InPrefDirFlag =
false;
15761 if(SearchElement.
XLink == PrefDirElement1.
XLink)
15763 SearchElement = PrefDirElement1;
15764 InPrefDirFlag =
true;
15766 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
15768 SearchElement = PrefDirElement2;
15769 InPrefDirFlag =
true;
15775 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15779 for(
int x = 0; x < VectorCount; x++)
15797 AutoSigsFlag,
true))
15806 for(
int x = 0; x < VectorCount; x++)
15815 for(
int x = 0; x < VectorCount; x++)
15835 for(
int x = 0; x < VectorCount; x++)
15845 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
15846 SearchElement.
XLinkPos = SearchPos2;
15847 if(SearchElement.
XLink == PrefDirElement1.
XLink)
15849 SearchElement = PrefDirElement1;
15851 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
15853 SearchElement = PrefDirElement2;
15857 for(
int x = 0; x < VectorCount; x++)
15865 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15869 for(
int x = 0; x < VectorCount; x++)
15888 AutoSigsFlag,
true))
15897 for(
int x = 0; x < VectorCount; x++)
15906 for(
int x = 0; x < VectorCount; x++)
15918 for(
int x = 0; x < VectorCount; x++)
15928 SearchElement = PrefDirElement1;
15937 XLinkPos = SearchElement.
XLinkPos;
15938 PrefDirElement = SearchElement;
15995 unsigned int TruncatePrefDirPosition = 0;
16068 throw Exception(
"Error - failed to validate extended route for preferred route");
16123 throw Exception(
"Error - failed to validate single route for preferred route");
16168 AnsiString(VLoc) +
"," + AnsiString((
short)Callon));
16170 int TrackVectorPosition;
16207 int LockedVectorNumber;
16241 PrefDirElement1.
ELink = PrefDirElement1.
Link[0];
16242 PrefDirElement1.
XLink = PrefDirElement1.
Link[1];
16245 throw Exception(
"Error, No EXNumber for PrefDirElement1 in GetNonPreferredRouteStartElement");
16251 PrefDirElement2.
ELink = PrefDirElement2.
Link[1];
16252 PrefDirElement2.
XLink = PrefDirElement2.
Link[0];
16255 throw Exception(
"Error, No EXNumber for PrefDirElement2 in GetNonPreferredRouteStartElement");
16269 if(RoutePair.first > -1)
16404 int NewFailedPointsTVPos = -1;
16469 EndElement1.
ELink = EndElement1.
Link[0];
16470 EndElement1.
XLink = EndElement1.
Link[1];
16473 throw Exception(
"Error, No EXNumber for EndElement1 in GetNonPreferredRouteStartElement");
16478 EndElement2.
ELink = EndElement2.
Link[1];
16479 EndElement2.
XLink = EndElement2.
Link[0];
16482 throw Exception(
"Error, No EXNumber for EndElement2 in GetNonPreferredRouteStartElement");
16526 if(RoutePair.first > -1)
16528 if(RoutePair.second != 0)
16551 EndElement2 = BlankElement;
16636 if(NewFailedPointsTVPos > -1)
16640 " failed during route setting.");
16644 PointsChanged =
true;
16670 if(NewFailedPointsTVPos > -1)
16674 " failed during route setting.");
16678 PointsChanged =
true;
16700 if(NewFailedPointsTVPos > -1)
16704 " failed during route setting.");
16708 PointsChanged =
true;
16734 if(NewFailedPointsTVPos > -1)
16738 " failed during route setting.");
16742 PointsChanged =
true;
16756 if(NewFailedPointsTVPos > -1)
16760 " failed during route setting.");
16764 PointsChanged =
true;
16804 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString() +
"," + AnsiString(
ReqPosRouteID.
GetInt()));
16805 int VectorCount = 0;
16808 if((CurrentTrackElement.
Link[XLinkPos] == 1) || (CurrentTrackElement.
Link[XLinkPos] == 3) || (CurrentTrackElement.
Link[XLinkPos] == 7) ||
16809 (CurrentTrackElement.
Link[XLinkPos] == 9))
16813 for(
int x = 0; x < VectorCount; x++)
16825 for(
int x = 0; x < VectorCount; x++)
16832 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
16834 for(
int x = 0; x < VectorCount; x++)
16841 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
16845 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
16846 SearchElement.
ELinkPos = NextELinkPos;
16867 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
16869 SearchElement.
XLinkPos = NextXLinkPos;
16882 for(
int x = 0; x < VectorCount; x++)
16896 if(RoutePair.first > -1)
16905 for(
int x = 0; x < VectorCount; x++)
16914 if(SecondPair.first > -1)
16923 for(
int x = 0; x < VectorCount; x++)
16937 for(
int x = 0; x < VectorCount; x++)
16948 for(
int x = 0; x < VectorCount; x++)
16957 for(
int x = 0; x < VectorCount; x++)
16966 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16970 for(
int x = 0; x < VectorCount; x++)
16983 for(
int x = 0; x < VectorCount; x++)
17011 for(
int x = 0; x < VectorCount; x++)
17024 for(
int x = 0; x < VectorCount; x++)
17034 for(
int x = 0; x < VectorCount; x++)
17059 for(
int x = 0; x < VectorCount; x++)
17068 for(
int x = 0; x < VectorCount; x++)
17081 int SearchPos1 = SearchElement.
Attribute + 1;
17083 if(SearchPos1 == 2)
17087 if(SearchPos1 == 1)
17096 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
17097 SearchElement.
XLinkPos = SearchPos1;
17099 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
17103 for(
int x = 0; x < VectorCount; x++)
17121 for(
int x = 0; x < VectorCount; x++)
17137 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
17138 SearchElement.
XLinkPos = SearchPos2;
17140 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
17144 for(
int x = 0; x < VectorCount; x++)
17160 for(
int x = 0; x < VectorCount; x++)
17172 for(
int x = 0; x < VectorCount; x++)
17187 CurrentTrackElement = SearchElement;
17188 XLinkPos = SearchElement.
XLinkPos;
17210 throw Exception(
"Error, SearchVector empty");
17222 for(
int x = 0; x < 4; x++)
17264 throw Exception(
"Error in EntryExitNumber 3");
17319 unsigned int TruncatePrefDirPosition = 0;
17379 throw Exception(
"Failed to validate extended route for nonpreferred route");
17424 throw Exception(
"Failed to validate single route for nonpreferred route");
17444 if(!PrefDirVector.empty())
17448 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 1) || (PrefDirPtr->XLinkPos == 1)))
17453 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 3) || (PrefDirPtr->XLinkPos == 3)))
17488 if(!PrefDirVector.empty())
17491 TPrefDirElement LastElement = GetFixedPrefDirElementAt(185, PrefDirSize() - 1);
17493 int ForwardLinkedRouteNumber, Attribute = 0;
17500 if(ForwardLinkedRouteNumber > -1)
17502 int NextForwardLinkedRouteNumber = -1;
17506 ForwardLinkedRouteNumber = NextForwardLinkedRouteNumber;
17517 GetFixedPrefDirElementAt(193, 0).XLinkPos, RouteNumber);
17534 NewFailedPointsTVPos = -1;
17535 bool PointsChanged =
false;
17543 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 1) || (SearchPtr->XLinkPos == 1)))
17553 NewFailedPointsTVPos = SearchPtr->TrackVectorPosition;
17554 IFE.
TVPos = NewFailedPointsTVPos;
17573 PointsChanged =
true;
17576 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 3) || (SearchPtr->XLinkPos == 3)))
17586 NewFailedPointsTVPos = SearchPtr->TrackVectorPosition;
17587 IFE.
TVPos = NewFailedPointsTVPos;
17606 PointsChanged =
true;
17612 return(PointsChanged);
17633 NextForwardLinkedRouteNumber = -1;
17634 for(
unsigned int x = 0; x < PrefDirSize(); x++)
17636 int TrainID =
Track->
TrackElementAt(100, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnElement;
17637 if(PrefDirVector.at(x).TrackType ==
Bridge)
17639 if(PrefDirVector.at(x).XLinkPos < 2)
17641 TrainID =
Track->
TrackElementAt(101, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeOrFailedPointOrigSpeedLimit01;
17645 TrainID =
Track->
TrackElementAt(102, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeOrFailedPointOrigSpeedLimit23;
17653 if(PrefDirVector.at(x).TrackType ==
Buffers)
17665 if(
Track->
IsLCAtHV(42, PrefDirVector.at(x).HLoc, PrefDirVector.at(x).VLoc))
17674 if(PrefDirVector.at(x).Config[PrefDirVector.at(x).XLinkPos] ==
Signal)
17676 Attribute =
Track->
TrackElementAt(103, PrefDirVector.at(x).TrackVectorPosition).Attribute;
17688 if(x == PrefDirSize() - 1)
17732 AnsiString(PrefDirVectorStartPosition));
17737 bool SkipContinuationAndBufferAttributeChange =
false;
17739 if(!PrefDirVector.empty())
17741 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr < PrefDirVector.end(); PrefDirPtr++)
17744 if(PrefDirPtr->TrackType ==
Bridge)
17746 if(PrefDirPtr->XLinkPos < 2)
17757 SkipContinuationAndBufferAttributeChange =
true;
17772 SkipContinuationAndBufferAttributeChange =
true;
17780 SkipContinuationAndBufferAttributeChange =
true;
17782 if(!SkipContinuationAndBufferAttributeChange)
17784 if(PrefDirVector.back().TrackType ==
Buffers)
17793 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr >= PrefDirVector.begin(); PrefDirPtr--)
17796 if(PrefDirPtr->TrackType ==
Bridge)
17798 if(PrefDirPtr->XLinkPos < 2)
17814 if(
Track->
IsLCAtHV(20, PrefDirPtr->HLoc, PrefDirPtr->VLoc))
17823 if(PrefDirPtr->Config[PrefDirPtr->XLinkPos] ==
Signal)
17826 PrefDirPtr->PrefDirRoute)
17830 int LockedVecNum = 0;
17832 bool KeepAttributeAt0ForLockedRoute =
false;
17837 KeepAttributeAt0ForLockedRoute =
true;
17842 bool NotGroundSignal =
false;
17845 NotGroundSignal =
true;
17870 if((Attribute < 3) && !KeepAttributeAt0ForLockedRoute && (NotGroundSignal || (Attribute == 0)))
17899 "," + AnsiString((
short)PrefDirRoute));
17900 bool ElementInRoute =
false;
17901 bool MovingTrainOccupyingRoute =
false;
17902 unsigned int TruncatePDElementPos;
17903 enum {NoTruncate, BackTruncate, FrontTruncate, FullTruncate} TruncateType;
17904 TruncateType = NoTruncate;
17911 TruncatePDElementPos = b;
17912 ElementInRoute =
true;
17916 if(!ElementInRoute)
17926 if(TruncatePDElementPos == 0)
17928 TruncateType = FullTruncate;
17936 TruncateType = FrontTruncate;
17940 TruncateType = BackTruncate;
17947 TruncateType = BackTruncate;
17953 if(TruncateType == BackTruncate)
17973 MovingTrainOccupyingRoute =
true;
17984 if(b ==
int(TruncatePDElementPos))
17990 else if(TruncateType == FrontTruncate)
18010 MovingTrainOccupyingRoute =
true;
18021 if(b == TruncatePDElementPos)
18047 MovingTrainOccupyingRoute =
true;
18069 if(((TruncatePDElementPos == 1) && (TruncateType == BackTruncate)) || ((TruncatePDElementPos == (
PrefDirSize() - 2)) && (TruncateType == FrontTruncate)))
18078 if((TruncatePDElementPos > 0) && (TruncateType == BackTruncate))
18085 TrainController->
StopTTClockMessage(145,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18086 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18087 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18107 else if((TruncatePDElementPos < (
PrefDirSize() - 1)) && (TruncateType == FrontTruncate))
18114 TrainController->
StopTTClockMessage(146,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18115 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18116 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18125 if(TruncatePDElementPos > 0)
18140 else if(TruncatePDElementPos == 0)
18147 TrainController->
StopTTClockMessage(148,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18148 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18149 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18169 int ThisRouteNumber;
18179 if(LRVIT->RouteNumber == ThisRouteNumber)
18190 unsigned int LookBackwardsFromHere = 0;
18191 if(TruncateType == BackTruncate)
18193 LookBackwardsFromHere = TruncatePDElementPos;
18205 int button = Application->MessageBox(L
"Moving train approaching or occupying route, YES to lock route (2 minutes to release), NO to cancel",
18206 L
"Warning!", MB_YESNO | MB_ICONWARNING);
18219 bool ExistingLockedRouteModified =
false;
18221 if(TruncateType == BackTruncate)
18227 else if(TruncateType == FrontTruncate)
18248 if(LRVIT->RouteNumber == ThisRouteNumber)
18252 ExistingLockedRouteModified =
true;
18256 if(!ExistingLockedRouteModified)
18260 if(TruncateType == BackTruncate)
18263 RearPosition = TruncatePDElementPos;
18266 else if(TruncateType == FrontTruncate)
18270 FrontPosition = TruncatePDElementPos;
18279 for(
int c = FrontPosition; c >= RearPosition; c--)
18297 if(TruncateType == BackTruncate)
18299 RearPosition = TruncatePDElementPos;
18303 else if(TruncateType == FrontTruncate)
18306 FrontPosition = TruncatePDElementPos;
18323 for(
int c = FrontPosition; c >= RearPosition; c--)
18367 TPrefDirElement NewGreenFirstPDElement, NewRedFirstPDElement, NewGreenLastPDElement, NewRedLastPDElement;
18380 if(RouteColour == 1)
18382 NewRedFirstPDElement = LastPDElement;
18386 NewRedFirstPDElement.
IsARoute =
true;
18392 if(R2MMIt->second.first ==
int(x))
18394 R2MMIt->second.second++;
18401 else if(RouteColour == 2)
18403 NewGreenFirstPDElement = LastPDElement;
18407 NewGreenFirstPDElement.
IsARoute =
true;
18413 if(R2MMIt->second.first ==
int(x))
18415 R2MMIt->second.second++;
18438 if(RouteColour == 1)
18440 NewRedLastPDElement = FirstPDElement;
18449 else if(RouteColour == 2)
18451 NewGreenLastPDElement = FirstPDElement;
18528 AnsiString((
short)PrefDirRoute));
18553 AnsiString((
short)PrefDirRoute));
18563 RouteFlashElement.
HLoc = H;
18564 RouteFlashElement.
VLoc = V;
18580 int H = PrefDirPtr->HLoc;
18581 int V = PrefDirPtr->VLoc;
18648 for(
unsigned int x = 0; x < RouteFlashVector.size(); x++)
18654 Display->
PlotOutput(21, RouteFlashVector.at(x).HLoc * 16, RouteFlashVector.at(x).VLoc * 16, RouteFlashVector.at(x).OriginalGraphic);
18657 OverlayPlotted =
false;
18680 bool FirstSignalFound =
false;
18687 if(PDVIt->TrackType ==
Points)
18689 if((PDVIt->ELinkPos == 1) || (PDVIt->XLinkPos == 1))
18700 else if((PDVIt->ELinkPos == 3) || (PDVIt->XLinkPos == 3))
18715 int XLinkPosition = PDVIt->XLinkPos;
18716 if(PDVIt->XLinkPos == -1)
18720 for(
int x = 0; x < 4; x++)
18722 if(PDVIt->Conn[x] == (PDVIt + 1)->TrackVectorPosition)
18735 if(XLinkPosition > -1)
18737 if(!FirstSignalFound && (PDVIt->Config[XLinkPosition] ==
Signal))
18739 FirstSignalFound =
true;
18742 else if(FirstSignalFound && (PDVIt->Config[XLinkPosition] ==
Signal))
18753 IFE.
TVPos = PDVIt->TrackVectorPosition;
18759 " failed when changing aspect.\nTrains can only pass under signaller control.");
18789 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
18791 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedRouteAt");
18794 return(AllRoutesVector.at(At));
18802 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
18804 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableRouteAt");
18807 return(AllRoutesVector.at(At));
18818 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
18820 GetFixedRouteAt(62, a).PrefDirMarker(7,
RouteCall,
false, Disp);
18830 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
18832 GetFixedRouteAt(166, a).RouteImageMarker(0, Bitmap);
18850 AnsiString(VLoc) +
"," + AnsiString((
short)PrefDirRoute));
18851 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
18855 GetModifiableRouteAt(7, a).TruncateRoute(0, HLoc, VLoc, PrefDirRoute, ReturnFlag);
18884 AnsiString(LinkPos));
18885 if(TrackVectorPosition == -1)
18890 THVPair Route2MultiMapKeyPair;
18894 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
18897 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
18907 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
18909 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
18912 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(64, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(88,
18913 Route2MultiMapIterator->second.second);
18914 EntryLinkPos = PrefDirElement1.
ELinkPos;
18915 ExitLinkPos = PrefDirElement1.
XLinkPos;
18916 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
18917 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
18929 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
18941 Graphics::TBitmap* &EntryDirectionGraphicPtr)
18951 AnsiString(LinkPos));
18954 if(TrackVectorPosition == -1)
18959 THVPair Route2MultiMapKeyPair;
18963 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
18966 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
18971 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
18973 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
18975 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(73, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(97,
18976 Route2MultiMapIterator->second.second);
18977 EntryLinkPos = PrefDirElement1.
ELinkPos;
18978 ExitLinkPos = PrefDirElement1.
XLinkPos;
18979 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
18980 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
18984 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(74,
18985 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
18992 return(AutoSigsRoute);
18997 return(NotAutoSigsRoute);
19003 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(75,
19004 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
19011 return(AutoSigsRoute);
19016 return(NotAutoSigsRoute);
19020 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19022 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19023 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19025 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(76, ItPair.first->second.first).GetFixedPrefDirElementAt(98, ItPair.first->second.second);
19026 EntryLinkPos = PrefDirElement2.
ELinkPos;
19027 ExitLinkPos = PrefDirElement2.
XLinkPos;
19028 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
19029 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
19033 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(77, ItPair.first->second.first).PrefDirSize() - 1))
19040 return(AutoSigsRoute);
19045 return(NotAutoSigsRoute);
19051 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(78, ItPair.first->second.first).PrefDirSize() - 1))
19058 return(AutoSigsRoute);
19063 return(NotAutoSigsRoute);
19067 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(79, ItPair.second->second.first).GetFixedPrefDirElementAt(99, ItPair.second->second.second);
19068 EntryLinkPos = PrefDirElement3.
ELinkPos;
19069 ExitLinkPos = PrefDirElement3.
XLinkPos;
19070 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
19071 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
19075 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(80, ItPair.second->second.first).PrefDirSize() - 1))
19082 return(AutoSigsRoute);
19087 return(NotAutoSigsRoute);
19093 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(81, ItPair.second->second.first).PrefDirSize() - 1))
19100 return(AutoSigsRoute);
19105 return(NotAutoSigsRoute);
19121 AnsiString(LinkPos));
19122 if(TrackVectorPosition == -1)
19128 THVPair Route2MultiMapKeyPair;
19132 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
19135 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
19141 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
19143 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
19145 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(82, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(100,
19146 Route2MultiMapIterator->second.second);
19147 EntryLinkPos = PrefDirElement1.
ELinkPos;
19148 ExitLinkPos = PrefDirElement1.
XLinkPos;
19149 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
19150 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
19153 RouteNumber = Route2MultiMapIterator->second.first;
19157 return(AutoSigsRoute);
19162 return(NotAutoSigsRoute);
19167 RouteNumber = Route2MultiMapIterator->second.first;
19171 return(AutoSigsRoute);
19176 return(NotAutoSigsRoute);
19180 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19182 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19183 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19185 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(83, ItPair.first->second.first).GetFixedPrefDirElementAt(101, ItPair.first->second.second);
19186 EntryLinkPos = PrefDirElement2.
ELinkPos;
19187 ExitLinkPos = PrefDirElement2.
XLinkPos;
19188 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
19189 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
19192 RouteNumber = ItPair.first->second.first;
19196 return(AutoSigsRoute);
19201 return(NotAutoSigsRoute);
19206 RouteNumber = ItPair.first->second.first;
19210 return(AutoSigsRoute);
19215 return(NotAutoSigsRoute);
19219 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(84, ItPair.second->second.first).GetFixedPrefDirElementAt(102, ItPair.second->second.second);
19220 EntryLinkPos = PrefDirElement3.
ELinkPos;
19221 ExitLinkPos = PrefDirElement3.
XLinkPos;
19222 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
19223 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
19226 RouteNumber = ItPair.second->second.first;
19230 return(AutoSigsRoute);
19235 return(NotAutoSigsRoute);
19240 RouteNumber = ItPair.second->second.first;
19244 return(AutoSigsRoute);
19249 return(NotAutoSigsRoute);
19271 EmptyRoute.
RouteID = NextRouteID;
19274 AllRoutesVector.push_back(EmptyRoute);
19275 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
19300 AllRoutesVector.push_back(EmptyRoute);
19301 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
19324 THVPair Route2MultiMapKeyPair;
19333 LockedRouteRearTrackVectorPosition = 0;
19334 LockedRouteLastTrackVectorPosition = 0;
19335 LockedRouteLastXLinkPos = 0;
19336 LockedRouteLockStartTime = TDateTime(0);
19337 if(!LockedRouteVector.empty())
19341 if(LRVIT->RouteNumber == RouteNumber)
19343 LockedRouteRearTrackVectorPosition = LRVIT->RearTrackVectorPosition;
19344 LockedRouteLastTrackVectorPosition = LRVIT->LastTrackVectorPosition;
19345 LockedRouteLastXLinkPos = LRVIT->LastXLinkPos;
19346 LockedRouteLockStartTime = LRVIT->LockStartTime;
19347 LockedRouteFoundDuringRouteBuilding =
true;
19348 LockedRouteVector.erase(LRVIT);
19373 AnsiString(VLoc) +
"," + AnsiString(ELink));
19376 ReturnPair.first = -1;
19377 ReturnPair.second = 0;
19378 THVPair Route2MultiMapKeyPair;
19380 Route2MultiMapKeyPair.first = HLoc;
19381 Route2MultiMapKeyPair.second = VLoc;
19384 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
19385 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19387 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19388 Route2MultiMapIterator = ItPair.first;
19390 if(ItPair.first == ItPair.second)
19392 throw Exception(
"Failed to find Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc);
19394 if(GetFixedRouteAt(111, ItPair.first->second.first).GetFixedPrefDirElementAt(132, ItPair.first->second.second).GetELink() == ELink)
19396 ReturnPair.first = ItPair.first->second.first;
19397 ReturnPair.second = ItPair.first->second.second;
19398 Route2MultiMapIterator = ItPair.first;
19400 return(ReturnPair);
19403 if(ItPair.first == ItPair.second)
19405 throw Exception(
"Found Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc +
" but failed to find required element");
19407 if(GetFixedRouteAt(112, ItPair.first->second.first).GetFixedPrefDirElementAt(133, ItPair.first->second.second).GetELink() == ELink)
19409 ReturnPair.first = ItPair.first->second.first;
19410 ReturnPair.second = ItPair.first->second.second;
19411 Route2MultiMapIterator = ItPair.first;
19413 return(ReturnPair);
19416 return(ReturnPair);
19431 AnsiString(VLoc) +
"," + AnsiString(ELink));
19432 THVPair Route2MultiMapKeyPair;
19434 Route2MultiMapKeyPair.first = HLoc;
19435 Route2MultiMapKeyPair.second = VLoc;
19436 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19438 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19440 if(ItPair.first == ItPair.second)
19446 if(GetFixedRouteAt(205, ItPair.first->second.first).GetFixedPrefDirElementAt(241, ItPair.first->second.second).GetELink() == ELink)
19448 RouteNumber = ItPair.first->second.first;
19454 if(ItPair.first == ItPair.second)
19460 if(GetFixedRouteAt(206, ItPair.first->second.first).GetFixedPrefDirElementAt(242, ItPair.first->second.second).GetELink() == ELink)
19462 RouteNumber = ItPair.first->second.first;
19483 "," + AnsiString(ELinkIn) +
"," + AnsiString(RouteNumber) +
"," + AnsiString(RouteElementNumber));
19484 THVPair Route2MultiMapKeyPair;
19486 Route2MultiMapKeyPair.first = HLoc;
19487 Route2MultiMapKeyPair.second = VLoc;
19490 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
19493 RouteElementPair.first = RouteNumber;
19494 RouteElementPair.second = RouteElementNumber;
19495 Route2MultiMapEntry.second = RouteElementPair;
19497 if(Route2MultiMap.find(Route2MultiMapKeyPair) != Route2MultiMap.end())
19500 if(GetFixedRouteAt(113, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(134,
19501 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).GetELink() != ELinkIn)
19504 if(GetFixedRouteAt(114, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(135,
19505 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).TrackType !=
Bridge)
19507 throw Exception(
"Error, bridge expected in Route2MultiMapInsert but not, at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
19509 Route2MultiMap.insert(Route2MultiMapEntry);
19514 throw Exception(
"Error, route map entry found in Route2MultiMapInsert at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
19519 Route2MultiMap.insert(Route2MultiMapEntry);
19537 TempPair.first = -1;
19538 TempPair.second = 0;
19539 SecondPair = TempPair;
19541 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItRange;
19542 THVPair Route2MultiMapKeyPair;
19544 Route2MultiMapKeyPair.first = HLoc;
19545 Route2MultiMapKeyPair.second = VLoc;
19546 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
19551 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
19553 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
19555 return(Route2MultiMapIterator->second);
19557 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19559 ItRange = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19560 TempPair = ItRange.first->second;
19561 SecondPair = (--ItRange.second)->second;
19584 TRouteElementPair RouteElementPair = GetRouteElementDataFromRoute2MultiMap(8, CheckElement.
HLoc, CheckElement.
VLoc, SecondPair);
19585 if(RouteElementPair.first == -1)
19588 throw Exception(
"CheckMapAndRoutes Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
19589 " in Route2MultiMap, Caller=" + (AnsiString)Caller);
19591 if((RouteElementPair.first != (
int)a) && (SecondPair.first != (
int)a))
19594 throw Exception(
"CheckMapAndRoutes Error - RouteNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
19595 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)RouteElementPair.first +
" Route value=" + (AnsiString)a +
" Caller=" +
19596 (AnsiString)Caller);
19598 if(((RouteElementPair.first != (
int)a) || (RouteElementPair.second != b)) && ((SecondPair.first != (
int)a) || (SecondPair.second != b)))
19601 throw Exception(
"CheckMapAndRoutes Error - PrefDirVectorNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
19602 (AnsiString)CheckElement.
VLoc +
" 1st Map value RouteNum/ElementNum =" + (AnsiString)RouteElementPair.first +
"/" +
19603 (AnsiString)RouteElementPair.second +
" 2nd Map value =" + (AnsiString)SecondPair.first +
"/" + (AnsiString)SecondPair.second +
19604 " Route value=" + (AnsiString)a +
"/" + (AnsiString)b +
" Caller=" + (AnsiString)Caller);
19608 unsigned int SizeVal = 0;
19611 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
19613 SizeVal += GetFixedRouteAt(117, a).PrefDirSize();
19615 if(SizeVal != Route2MultiMap.size())
19617 throw Exception(
"CheckMapAndRoutes Error - Map Size=" + (AnsiString)Route2MultiMap.size() +
" RouteSize=" + (AnsiString)SizeVal +
" Caller=" +
19618 (AnsiString)Caller);
19634 if(!Route2MultiMap.empty())
19636 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
19638 if(Route2MultiMapIterator->second.first > RouteNumber)
19640 Route2MultiMapIterator->second.first--;
19657 AnsiString(RouteNumber) +
"," + AnsiString(ErasedElementNumber));
19658 if(!Route2MultiMap.empty())
19660 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
19662 if((Route2MultiMapIterator->second.first == RouteNumber) && (Route2MultiMapIterator->second.second > ErasedElementNumber))
19664 Route2MultiMapIterator->second.second--;
19683 AnsiString(ELink));
19687 RequiredRoutePair = FindRoutePairFromRoute2MultiMap(0, HLoc, VLoc, ELink, Route2MultiMapIterator);
19688 if(RequiredRoutePair.first == -1)
19690 throw Exception(
"Failed to find route element in RemoveRouteElement");
19692 Route2MultiMap.erase(Route2MultiMapIterator);
19693 DecrementRouteElementNumbersInRoute2MultiMap(0, RequiredRoutePair.first, RequiredRoutePair.second);
19696 TPrefDirElement LockedRouteElement, PrefDirElement = GetFixedRouteAt(118, RequiredRoutePair.first).GetFixedPrefDirElementAt(137, RequiredRoutePair.second);
19717 GetModifiableRouteAt(8, RequiredRoutePair.first).PrefDirVector.erase(GetModifiableRouteAt(33, RequiredRoutePair.first).PrefDirVector.begin() + RequiredRoutePair.second);
19728 if(AutoSigVectorIT->RouteNumber == RequiredRoutePair.first)
19736 if(GetModifiableRouteAt(10, RequiredRoutePair.first).PrefDirSize() == 0)
19738 TrainController->
LogEvent(
"RouteRemoved," + AnsiString(GetFixedRouteAt(189, RequiredRoutePair.first).RouteID));
19739 AllRoutesVector.erase(AllRoutesVector.begin() + RequiredRoutePair.first);
19740 DecrementRouteNumbersInRoute2MultiMap(0, RequiredRoutePair.first);
19752 if(!LockedRouteVector.empty())
19756 if(LRVIT->RouteNumber > RequiredRoutePair.first)
19758 LRVIT->RouteNumber--;
19768 if(AutoSigVectorIT->RouteNumber > RequiredRoutePair.first)
19770 AutoSigVectorIT->RouteNumber--;
19775 CheckMapAndRoutes(7);
19789 AnsiString(ELink) +
"," + AnsiString(RouteNumber) +
"," + RouteElement.
LogPrefDir());
19790 GetModifiableRouteAt(11, RouteNumber).StoreRouteElementInPrefDirVector(RouteElement);
19791 Route2MultiMapInsert(0, HLoc, VLoc, ELink, RouteNumber, GetModifiableRouteAt(12, RouteNumber).
PrefDirSize() - 1);
19807 "," + AnsiString(XLinkPos));
19811 RouteElementPair = GetRouteElementDataFromRoute2MultiMap(9, TE.
HLoc, TE.
VLoc, SecondPair);
19812 if(RouteElementPair.first == -1)
19814 throw Exception(
"Error, failed to find element in SetTrailingSignalsOnAutoSigsRoute - 1");
19816 TPrefDirElement RouteElement = GetFixedRouteAt(119, RouteElementPair.first).GetFixedPrefDirElementAt(138, RouteElementPair.second);
19818 RequiredPair = RouteElementPair;
19819 if(RouteElement.
XLinkPos != XLinkPos)
19821 if(SecondPair.first != -1)
19823 RouteElement = GetFixedRouteAt(120, SecondPair.first).GetFixedPrefDirElementAt(139, SecondPair.second);
19824 RequiredPair = SecondPair;
19825 if(RouteElement.
XLinkPos != XLinkPos)
19827 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 2");
19832 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 3");
19836 SetAllRearwardsSignals(5, 0, RequiredPair.first, RequiredPair.second);
19856 AnsiString(AccessNumber));
19858 int Attribute = AccessNumber + 1;
19860 int x = GetFixedRouteAt(121, RouteNumber).PrefDirSize() - 1;
19864 throw Exception(
"Error - route not AutoSignals in SetTrailingSignalsOnContinuationRoute");
19868 throw Exception(
"Error - end element not continuation in SetTrailingSignalsOnContinuationRoute");
19871 x).XLinkPos] !=
End)
19873 throw Exception(
"Error - end element a continuation in SetTrailingSignalsOnContinuationRoute but End not facing right way");
19876 SetAllRearwardsSignals(6, Attribute, RouteNumber, GetFixedRouteAt(126, RouteNumber).
PrefDirSize() - 1);
19919 AnsiString(RouteNumber) +
"," + AnsiString(RouteStartPosition));
19920 TPrefDirElement FirstElement = GetFixedRouteAt(127, RouteNumber).GetFixedPrefDirElementAt(144, 0);
19921 int RearwardLinkedRouteNumber;
19947 int TrainID, TrainPosition, BehindTrainPosition;
19948 bool FoundTrain =
false, BehindTrain =
false;
19949 for(
int x = RouteStartPosition; x >= 0; x--)
19951 TPrefDirElement PrefDirElement = GetFixedRouteAt(132, RouteNumber).GetFixedPrefDirElementAt(146, x);
19976 if(FoundTrain && (TrainPosition > 1))
19978 for(
int x = TrainPosition; x >= 0; x--)
19983 TPrefDirElement PrefDirElement = GetFixedRouteAt(133, RouteNumber).GetFixedPrefDirElementAt(147, x);
20003 BehindTrain =
true;
20004 BehindTrainPosition = x;
20011 SetAllRearwardsSignals(7, 0, RouteNumber, BehindTrainPosition);
20028 AnsiString(LookBackwardsFromHere));
20029 int SignalCount = 0, TrainID, RearwardLinkedRouteNumber;
20030 TOneRoute CurrentRoute = GetFixedRouteAt(134, RouteNumber);
20033 bool ExamineRoute =
true;
20035 while(ExamineRoute)
20037 for(
int x = LookBackwardsFromHere; x >= 0; x--)
20082 if(SignalCount >= 3)
20097 LookBackwardsFromHere = CurrentRoute.
PrefDirSize() - 1;
20101 CurrentRoute = GetFixedRouteAt(135, RearwardLinkedRouteNumber);
20102 ExamineRoute =
true;
20103 LookBackwardsFromHere = GetFixedRouteAt(136, RearwardLinkedRouteNumber).PrefDirSize() - 1;
20138 ExamineRoute =
false;
20153 AnsiString(TrackVectorPosition) +
"," + AnsiString(XLinkPos));
20156 PrefDirElement = InternalPrefDirElement;
20157 if(LockedRouteVector.empty())
20164 bool InLockedRoute =
false;
20168 if(TrackIsInARoute(14, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos))
20172 InLockedRoute =
true;
20181 int RouteNumber, VectorCount = 0;
20186 RouteType = GetRouteTypeAndNumber(8, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos, RouteNumber);
20187 if(RouteType == NoRoute)
20200 for(
int x = GetFixedRouteAt(141, RouteNumber).
PrefDirSize() - 1; x >= 0; x--)
20202 InternalPrefDirElement = GetFixedRouteAt(142, RouteNumber).GetFixedPrefDirElementAt(152, x);
20207 PrefDirElement = InternalPrefDirElement;
20208 LockedVectorNumber = VectorCount;
20213 else if(InternalPrefDirElement.
TrackVectorPosition == (
int)LRVIT->RearTrackVectorPosition)
20217 PrefDirElement = InternalPrefDirElement;
20218 LockedVectorNumber = VectorCount;
20239 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20241 if(GetFixedRouteAt(157, x).RouteID ==
RouteID.GetInt())
20247 throw Exception(
"Error, failed to find RouteID in GetRouteVectorNumber for ID: " + AnsiString(
RouteID.GetInt()));
20257 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20259 if(GetFixedRouteAt(45, x).RouteID ==
RouteID.GetInt())
20274 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20276 if(GetFixedRouteAt(163, x).RouteID ==
RouteID.GetInt())
20279 return(GetFixedRouteAt(159, x));
20282 throw Exception(
"Error, failed to find RouteID in GetFixedRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
20290 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20292 if(GetFixedRouteAt(164, x).RouteID ==
RouteID.GetInt())
20295 return(GetModifiableRouteAt(15, x));
20298 throw Exception(
"Error, failed to find RouteID in GetModifiableRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
20308 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20310 TOneRoute OneRoute = GetFixedRouteAt(165, x);
20322 int NumberOfRoutes;
20326 for(
int x = 0; x < NumberOfRoutes; x++)
20333 StoreOneRouteAfterSessionLoad(0, &OneRoute);
20351 if((NumberOfRoutes < 0) || (NumberOfRoutes > 5000))
20358 if((NextID < 0) || (NextID > 1000000))
20363 for(
int x = 0; x < NumberOfRoutes; x++)
20388 AnsiString(StartPosition));
20389 if(EndPosition == StartPosition)
20395 int TVPos = EndPosition;
20396 int LkPos = EndXLinkPos;
20398 while(TrackIsInARoute(15, TVPos, LkPos))
20425 if(GetRouteTypeAndNumber(36, NewTVPos, NewLkPos, RouteNumber) == NoRoute)
20434 if((NewLkPos == 0) || (NewLkPos == 2))
20454 if(TVPos == StartPosition)
20486 AnsiString(VLoc) +
"," + AnsiString(DiagonalLinkNumber));
20491 if(FirstPair.first > -1)
20494 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20499 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20505 if(SecondPair.first > -1)
20508 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20513 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20519 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(0, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(1, HLoc - 1, VLoc,
20526 if(FirstPair.first > -1)
20529 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20534 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20540 if(SecondPair.first > -1)
20543 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20548 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20554 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(2, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(3, HLoc, VLoc - 1,
20561 if(FirstPair.first > -1)
20564 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20569 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20575 if(SecondPair.first > -1)
20578 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20583 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20589 if(((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(4, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(5, HLoc + 1, VLoc,
20596 if(FirstPair.first > -1)
20599 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20604 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20610 if(SecondPair.first > -1)
20613 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20618 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20624 if(((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(6, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(7, HLoc, VLoc + 1,
20648 "," + AnsiString(DiagonalLinkNumber));
20653 if(FirstPair.first > -1)
20656 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20661 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20667 if(SecondPair.first > -1)
20670 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20675 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20682 if(FirstPair.first > -1)
20685 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20690 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20696 if(SecondPair.first > -1)
20699 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20704 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20711 if(FirstPair.first > -1)
20714 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20719 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20725 if(SecondPair.first > -1)
20728 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20733 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20740 if(FirstPair.first > -1)
20743 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20748 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20754 if(SecondPair.first > -1)
20757 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20762 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))